ekyc

Electronic KYC process with uploading ID document using OAuth 2.1 (experimental)
Log | Files | Refs | README | LICENSE

email.ts (427B)


      1 import { EMAIL_REGEX } from "#core/domain/constants.ts";
      2 import { DomainError } from "#core/domain/error.ts";
      3 
      4 export class Email {
      5   constructor(readonly value: string) {
      6     if (!EMAIL_REGEX.test(value)) {
      7       throw new InvalidEmail(value);
      8     }
      9   }
     10 
     11   toString() {
     12     return this.value;
     13   }
     14 }
     15 
     16 export class InvalidEmail extends DomainError {
     17   constructor(readonly candidate: string) {
     18     super("Invalid email");
     19   }
     20 }