feat: Add Schema any
This commit is contained in:
parent
817b7d6774
commit
780423ab47
@ -1,5 +1,6 @@
|
|||||||
/* eslint-disable id-blacklist */
|
/* eslint-disable id-blacklist */
|
||||||
import { parseForm, parseFormData, parseQuery } from 'helpers'
|
import { parseForm, parseFormData, parseQuery } from 'helpers'
|
||||||
|
import SchemaAny from 'items/any'
|
||||||
import SchemaDate from 'items/date'
|
import SchemaDate from 'items/date'
|
||||||
import SchemaRecord from 'items/record'
|
import SchemaRecord from 'items/record'
|
||||||
import SchemaArray from './items/array'
|
import SchemaArray from './items/array'
|
||||||
@ -45,6 +46,7 @@ export function parceable() {
|
|||||||
type SchemaItemStatic = new (...args: Array<any>) => SchemaItem
|
type SchemaItemStatic = new (...args: Array<any>) => SchemaItem
|
||||||
|
|
||||||
export const Types = {
|
export const Types = {
|
||||||
|
Any: SchemaAny,
|
||||||
Array: SchemaArray,
|
Array: SchemaArray,
|
||||||
Boolean: SchemaBoolean,
|
Boolean: SchemaBoolean,
|
||||||
Date: SchemaDate,
|
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)
|
return this.registeredModules.find((it) => it.name === name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static any() {
|
||||||
|
return new SchemaAny()
|
||||||
|
}
|
||||||
|
|
||||||
public static array<Type extends SchemaItem>(
|
public static array<Type extends SchemaItem>(
|
||||||
...inputs: ConstructorParameters<typeof SchemaArray<Type>>
|
...inputs: ConstructorParameters<typeof SchemaArray<Type>>
|
||||||
): SchemaArray<Type> {
|
): SchemaArray<Type> {
|
||||||
@ -232,10 +238,9 @@ export * from './helpers'
|
|||||||
export type * from './types.d.ts'
|
export type * from './types.d.ts'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
SchemaArray,
|
SchemaAny, SchemaArray,
|
||||||
SchemaBoolean, SchemaDate, SchemaEnum, SchemaItem, SchemaLiteral,
|
SchemaBoolean, SchemaDate, SchemaEnum, SchemaItem, SchemaLiteral,
|
||||||
SchemaNullable,
|
SchemaNullable,
|
||||||
SchemaNumber,
|
SchemaNumber, SchemaObject, SchemaRecord, SchemaString,
|
||||||
SchemaObject, SchemaRecord, SchemaString,
|
|
||||||
SchemaUnion
|
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