maykinmedia / open-klant

Registratiecomponent voor de opslag en ontsluiting van klantgegevens volgens de Klantinteracties API-specificatie.
Other
2 stars 3 forks source link

Validation of any stored email address #234

Closed mariusvandam closed 2 weeks ago

mariusvandam commented 2 months ago

Thema / Theme

Klantinteracties API

Omschrijving / Description

It is desirable to have OpenKlant validate any email addresses before storing them so that they are stored in a consistent way.

Toegevoegde waarde / Added value

This make sure only valid mail addresses are stored and any connected system can rely on the provided addresses.

Aanvullende opmerkingen / Additional context

As discussed on 29-8 with Andy, ICATT & Maykin

andyverberne commented 2 months ago

Hieronder de conversie en validatie regels en patterns welke in e-Suite worden gehanteerd

    /**
     * Gebaseerd op RFC 5322 (zie ook http://en.wikipedia.org/wiki/Email_address)
     * <p>
     * We ondersteunen niet alles (een quoted local part bijvoorbeeld niet). 
     * Er wordt ook niet gecontroleerd op de top level domain-naam bestaat en of de domain-naam een MX-record heeft.
     */
    private static final String ID = "A-Za-z\\d";

    private static final String LCL = "[" + ID + "!#$%&\'*+\\-/=?^_`{|}~]+";

    private static final String LBL = "[" + ID + "]([" + ID + "\\-]*[" + ID + "])?";

    private static final String ADDRESS = LCL + "(\\." + LCL + ")*@" + LBL + "(\\." + LBL + ")+";

    public static final String EMAIL = "^" + ADDRESS + "$";

    public static final Pattern EMAIL_PATTERN = Pattern.compile(EMAIL);
sytskevanhasselt commented 6 days ago

At the risk of asking for the obvious: is there documentation of the exact validation, other then in andyverberne's comment? Is this something that one would find in a redoc?