Home > @opengovsg/validators > createUrlSchema
createUrlSchema() function
Create a schema that validates user-supplied URLs. This does the same thing as the UrlValidator class, but it returns a Zod schema which can be used as part of a larger schema.
Signature:
typescript
createUrlSchema: (options?: UrlValidatorOptions) => z.ZodType<URL, string>Parameters
| Parameter | Type | Description |
|---|---|---|
| options | UrlValidatorOptions | (Optional) The options to use for validation |
Returns:
z.ZodType<URL, string>
A Zod schema that validates paths.
Exceptions
OptionsError If the options are invalid