Skip to content

Instantly share code, notes, and snippets.

@gmdias727
Created December 20, 2025 02:41
Show Gist options
  • Select an option

  • Save gmdias727/2a06d50f0b3c10deefcb2ee9d05f462d to your computer and use it in GitHub Desktop.

Select an option

Save gmdias727/2a06d50f0b3c10deefcb2ee9d05f462d to your computer and use it in GitHub Desktop.
let is_valid ~email =
match (String.length email, email) with
| (0, _) -> Error "empty email is not valid"
| (len, _) when len > max_email_length -> Error "Email length exceeds the limit"
| (_, email) when string_is_bigger_than max_email_length [email] -> Error "Email is bigger than the limitations"
| _ -> Ok ()
@gmdias727
Copy link
Author

email.mli:

val max_recipient_length : int

val max_domain_length : int

val max_email_length : int

val validEmailRegex : Str.regexp

val string_is_bigger_than : int -> string list -> bool

(* val is_valid : email:string -> bool *)
val is_valid : email:string -> (unit, string) result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment