PhoneSchemaclass

new PhoneSchema({ one = "phone number", title = "Phone", input = "tel", max = 16, ...options }: PhoneSchemaOptions)
ParamType
optionsPhoneSchemaOptions
Options for a PhoneSchema. required
    .valuestring
Default string value used when the input is undefined. readonly
    .maxnumber
Maximum allowed character length. Defaults to 16 readonly
    .case"upper"
"lower"
Force the result to "upper" or "lower" case. readonly
    .inputStringInputType
HTML <input /> type="" hint for downstream UIs. Defaults to "tel" readonly
Return
PhoneSchema
Schema that defines a valid phone number.

Schema that defines a valid phone number.

  • Multiple string formats are automatically converted to E.164 format (starting with + plus).
  • Falsy values are converted to "" empty string.

Examples

PHONE.validate("+44 1234 567890"); // Returns "+441234567890"