PhoneSchemaclass
new PhoneSchema({ one = "phone number", title = "Phone", input = "tel", max = 16, ...options }: PhoneSchemaOptions)| Param | Type | |
|---|---|---|
options | PhoneSchemaOptions | Options for a PhoneSchema. required |
.value | string | Default string value used when the input is undefined. readonly |
.max | number | Maximum allowed character length. Defaults to 16 readonly |
.case | "upper""lower" | Force the result to "upper" or "lower" case. readonly |
.input | StringInputType | 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"