UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

27 lines (26 loc) 1.33 kB
import { type URISchemes } from "../util/uri.js"; import { type URLString } from "../util/url.js"; import type { StringSchemaOptions } from "./StringSchema.js"; import { StringSchema } from "./StringSchema.js"; /** Allowed options for `URLSchema` */ export interface URLSchemaOptions extends Omit<StringSchemaOptions, "input" | "min" | "max" | "rows"> { readonly base?: URL | URLString | undefined; readonly schemes?: URISchemes | undefined; } /** * Type of `StringSchema` that defines a valid URL string. * - Checks URL scheme against a whitelist (always), and checks URL domain against a whitelist (optional). * - URLs are limited to 512 characters, but generally these won't be data: URIs so this is a reasonable limit. */ export declare class URLSchema extends StringSchema { readonly base: URLString | undefined; readonly schemes: URISchemes; constructor({ one, title, base, schemes, ...options }: URLSchemaOptions); validate(unsafeValue: unknown): URLString; sanitize(str: string): string; format(value: string): string; } /** Valid URL string, e.g. `https://www.google.com` */ export declare const URL_SCHEMA: URLSchema; /** Valid URL string, e.g. `https://www.google.com`, or `null` */ export declare const NULLABLE_URL_SCHEMA: import("./NullableSchema.js").NullableSchema<string>;