From 780423ab472933de2bff0f3eddb2099ae4f2fd2a Mon Sep 17 00:00:00 2001 From: Avior Date: Tue, 25 Mar 2025 13:59:04 +0100 Subject: [PATCH] feat: Add Schema any --- src/Schema.ts | 11 ++++++++--- src/items/any.ts | 7 +++++++ 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 src/items/any.ts diff --git a/src/Schema.ts b/src/Schema.ts index 086b52c..f0d0fab 100644 --- a/src/Schema.ts +++ b/src/Schema.ts @@ -1,5 +1,6 @@ /* eslint-disable id-blacklist */ import { parseForm, parseFormData, parseQuery } from 'helpers' +import SchemaAny from 'items/any' import SchemaDate from 'items/date' import SchemaRecord from 'items/record' import SchemaArray from './items/array' @@ -45,6 +46,7 @@ export function parceable() { type SchemaItemStatic = new (...args: Array) => SchemaItem export const Types = { + Any: SchemaAny, Array: SchemaArray, Boolean: SchemaBoolean, Date: SchemaDate, @@ -79,6 +81,10 @@ export default class Schema = Record it.name === name) } + public static any() { + return new SchemaAny() + } + public static array( ...inputs: ConstructorParameters> ): SchemaArray { @@ -232,10 +238,9 @@ export * from './helpers' export type * from './types.d.ts' export { - SchemaArray, + SchemaAny, SchemaArray, SchemaBoolean, SchemaDate, SchemaEnum, SchemaItem, SchemaLiteral, SchemaNullable, - SchemaNumber, - SchemaObject, SchemaRecord, SchemaString, + SchemaNumber, SchemaObject, SchemaRecord, SchemaString, SchemaUnion } diff --git a/src/items/any.ts b/src/items/any.ts new file mode 100644 index 0000000..2925237 --- /dev/null +++ b/src/items/any.ts @@ -0,0 +1,7 @@ +import SchemaItem from '../SchemaItem' + +export default class SchemaAny extends SchemaItem { + public override isOfType(input: unknown): input is any { + return true + } +}