Skip to content

validateUrl

function validateUrl(
value,
path,
options?
): ValidationIssue[];

Defined in: src/util/validation.ts:209

Check an absolute URL against a policy; returns the issues (empty when the URL is acceptable). Dangerous schemes are always rejected.

Parameter Type
value unknown
path string
options? UrlPolicyOptions

ValidationIssue[]

// A webhook endpoint: https only (http on localhost), no credentials.
validateUrl(url, "endpoint.url", {
allowedSchemes: ["https:", "http:"],
requireHttps: true,
rejectCredentials: true,
});