UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

24 lines (23 loc) 1.14 kB
import { type URISchemes, type URIString } from "../util/uri.js"; import type { StringSchemaOptions } from "./StringSchema.js"; import { StringSchema } from "./StringSchema.js"; /** Allowed options for `URISchema` */ export interface URISchemaOptions extends Omit<StringSchemaOptions, "input" | "min" | "max" | "rows"> { readonly schemes?: URISchemes | undefined; } /** * Type of `StringSchema` that defines a valid URI string. * - Checks 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. */ export declare class URISchema extends StringSchema { readonly schemes: URISchemes; constructor({ one, title, schemes, ...options }: URISchemaOptions); validate(unsafeValue: unknown): URIString; sanitize(str: string): string; format(value: string): string; } /** Valid URI string, e.g. `https://www.google.com` */ export declare const URI_SCHEMA: URISchema; /** Valid URI string, e.g. `https://www.google.com`, or `null` */ export declare const NULLABLE_URI_SCHEMA: import("./NullableSchema.js").NullableSchema<string>;