valibot-schema-semver
Version:
Valibot schema for Semantic Versioning
32 lines (28 loc) • 1.44 kB
TypeScript
import { CustomIssue, CustomSchema, ErrorMessage, InferOutput } from 'valibot';
/**
* A schema for validating Semantic Versioning {@see {@link https://semver.org/}}.
* @module
*/
/**
* Function to validate Semantic Versioning strings.
* @param overrideMessage - A string to override the default message or a callback to define a custom message function.
* @returns A custom schema for Semantic Versioning validation.
*/
declare const semver: (overrideMessage?: string | ((value: CustomIssue) => string)) => CustomSchema<string, ErrorMessage<CustomIssue>>;
/**
* Function to validate Semantic Versioning ranges.
* @param overrideMessage - A string to override the default message or a callback to define a custom message function.
* @returns A custom schema for Semantic Versioning validation.
*/
declare const semverRange: (overrideMessage?: string | ((value: CustomIssue) => string)) => CustomSchema<string, ErrorMessage<CustomIssue>>;
/**
* Type for the output of the Semantic Versioning schema.
* @typedef {InferOutput<ReturnType<typeof semver>>} SemverSchema
*/
type SemverSchema = InferOutput<ReturnType<typeof semver>>;
/**
* Type for the output of the Semantic Versioning range schema.
* @typedef {InferOutput<ReturnType<typeof semverRange>>} SemverRangeSchema
*/
type SemverRangeSchema = InferOutput<ReturnType<typeof semverRange>>;
export { type SemverRangeSchema, type SemverSchema, semver, semverRange };