feat: Add Schema any
This commit is contained in:
parent
817b7d6774
commit
780423ab47
@ -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<any>) => SchemaItem
|
||||
|
||||
export const Types = {
|
||||
Any: SchemaAny,
|
||||
Array: SchemaArray,
|
||||
Boolean: SchemaBoolean,
|
||||
Date: SchemaDate,
|
||||
@ -79,6 +81,10 @@ export default class Schema<T extends Record<string, SchemaItem> = Record<string
|
||||
return this.registeredModules.find((it) => it.name === name)
|
||||
}
|
||||
|
||||
public static any() {
|
||||
return new SchemaAny()
|
||||
}
|
||||
|
||||
public static array<Type extends SchemaItem>(
|
||||
...inputs: ConstructorParameters<typeof SchemaArray<Type>>
|
||||
): SchemaArray<Type> {
|
||||
@ -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
|
||||
}
|
||||
|
7
src/items/any.ts
Normal file
7
src/items/any.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import SchemaItem from '../SchemaItem'
|
||||
|
||||
export default class SchemaAny extends SchemaItem {
|
||||
public override isOfType(input: unknown): input is any {
|
||||
return true
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user