veffect
Version:
powerful TypeScript validation library built on the robust foundation of Effect combining exceptional type safety, high performance, and developer experience. Taking inspiration from Effect's functional principles, VEffect delivers a balanced approach tha
22 lines (21 loc) • 984 B
TypeScript
import { Schema, RefinableSchema, TransformableSchema, DefaultableSchema, NullableSchema } from '../types';
/**
* Literal schema interface
*/
export interface LiteralSchema<T extends string | number | boolean | null | undefined> extends Schema<T>, RefinableSchema<T, LiteralSchema<T>>, TransformableSchema<T, LiteralSchema<T>>, DefaultableSchema<T, LiteralSchema<T>>, NullableSchema<T, LiteralSchema<T>> {
readonly _tag: 'LiteralSchema';
readonly value: T;
}
/**
* Creates a schema that validates that a value exactly matches the provided literal value
*
* @param value The literal value to match against
* @returns A schema that validates against the exact literal value
*
* @example
* const adminTypeSchema = literal('admin');
* const userTypeSchema = literal('user');
* const boolSchema = literal(true);
* const nullSchema = literal(null);
*/
export declare function literal<T extends string | number | boolean | null | undefined>(value: T): LiteralSchema<T>;