URISchemaclass

new URISchema({ one = "URI", title = "URI", schemes = HTTP_SCHEMES, input = "url", max = 512, ...options }: URISchemaOptions)
ParamType
optionsURISchemaOptions
Options for URISchema. required
    .valuestring
Default string value used when the input is undefined. readonly
    .maxnumber
Maximum allowed character length. Defaults to 512 readonly
    .matchRegExp
Regular expression the sanitized string must match. readonly
    .case"upper"
"lower"
Force the result to "upper" or "lower" case. readonly
    .inputStringInputType
HTML <input /> type="" hint for downstream UIs. Defaults to "url" readonly
    .schemesURISchemes
Whitelist of allowed URI schemes. Defaults to HTTP_SCHEMES readonly
Return
URISchema
Schema that defines a valid absolute URI string.
PropertyType
.schemesURISchemes
Whitelist of allowed URI schemes, e.g. ["https:", "http:"]. required readonly

Schema that defines a valid absolute URI string.

  • Checks the URI scheme against a whitelist (always).
  • URIs are limited to 512 characters, but generally these won't be data: URIs so this is a reasonable limit.

Examples

const schema = new URISchema({});
	schema.validate("https://www.google.com") // "https://www.google.com/"