diff --git a/packages/all/CHANGELOG.md b/packages/all/CHANGELOG.md index fbb19cb..da11afa 100644 --- a/packages/all/CHANGELOG.md +++ b/packages/all/CHANGELOG.md @@ -1,5 +1,14 @@ # @typeschema/all +## 0.13.8 + +### Patch Changes + +- a7c09b6: feat: add support to fastest-validator +- Updated dependencies [a7c09b6] + - @typeschema/fastest-validator@0.1.0 + - @typeschema/main@0.13.8 + ## 0.13.7 ### Patch Changes diff --git a/packages/all/package.json b/packages/all/package.json index 65ce4d8..bac758b 100644 --- a/packages/all/package.json +++ b/packages/all/package.json @@ -2,7 +2,7 @@ "//": "This file is partially generated. Only some fields can be modified manually!", "name": "@typeschema/all", "//version": "This field is manually maintained.", - "version": "0.13.7", + "version": "0.13.8", "//description": "This field is manually maintained.", "description": "Universal adapter for schema validation", "keywords": [ diff --git a/packages/fastest-validator/CHANGELOG.md b/packages/fastest-validator/CHANGELOG.md new file mode 100644 index 0000000..10d3640 --- /dev/null +++ b/packages/fastest-validator/CHANGELOG.md @@ -0,0 +1,7 @@ +# @typeschema/fastest-validator + +## 0.1.0 + +### Minor Changes + +- a7c09b6: feat: add support to fastest-validator diff --git a/packages/fastest-validator/package.json b/packages/fastest-validator/package.json index 4035f20..fc0eab8 100644 --- a/packages/fastest-validator/package.json +++ b/packages/fastest-validator/package.json @@ -2,7 +2,7 @@ "//": "This file is partially generated. Only some fields can be modified manually!", "name": "@typeschema/fastest-validator", "//version": "This field is manually maintained.", - "version": "0.0.0", + "version": "0.1.0", "//description": "This field is manually maintained.", "description": "Reusable adapter for fastest-validator schemas", "keywords": [ diff --git a/packages/main/CHANGELOG.md b/packages/main/CHANGELOG.md index 5945944..36f6220 100644 --- a/packages/main/CHANGELOG.md +++ b/packages/main/CHANGELOG.md @@ -1,5 +1,13 @@ # @typeschema/main +## 0.13.8 + +### Patch Changes + +- a7c09b6: feat: add support to fastest-validator +- Updated dependencies [a7c09b6] + - @typeschema/fastest-validator@0.1.0 + ## 0.13.7 ### Patch Changes diff --git a/packages/main/package.json b/packages/main/package.json index a0092fd..a584ad1 100644 --- a/packages/main/package.json +++ b/packages/main/package.json @@ -2,7 +2,7 @@ "//": "This file is partially generated. Only some fields can be modified manually!", "name": "@typeschema/main", "//version": "This field is manually maintained.", - "version": "0.13.7", + "version": "0.13.8", "//description": "This field is manually maintained.", "description": "Universal adapter for schema validation", "keywords": [ diff --git a/packages/main/src/selector.ts b/packages/main/src/selector.ts index 4e6a4b2..8a9a856 100644 --- a/packages/main/src/selector.ts +++ b/packages/main/src/selector.ts @@ -4,34 +4,31 @@ import type {Kind} from '@sinclair/typebox'; import type {IfDefined, SchemaFrom} from '@typeschema/core'; import type {CoreValidator} from 'suretype'; -type IsTypeboxSchema = [IfDefined] extends [never] - ? false - : TSchema extends {[Kind]: unknown} - ? true - : false; +// prettier-ignore +type IsTypeboxSchema = + [IfDefined] extends [never] ? false + : TSchema extends {[Kind]: unknown} ? true + : false; function isTypeboxSchema( schema: SchemaFrom, ): schema is SchemaFrom { return typeof schema === 'object' && Symbol.for('TypeBox.Kind') in schema; } -type IsSuretypeSchema = [IfDefined>] extends [ - never, -] - ? false - : TSchema extends CoreValidator - ? true - : false; +// prettier-ignore +type IsSuretypeSchema = + [IfDefined>] extends [never] ? false + : TSchema extends CoreValidator ? true + : false; function isSuretypeSchema( schema: SchemaFrom, ): schema is SchemaFrom { return typeof schema === 'object' && '_annotations' in schema; } -type IsClassValidatorSchema = TSchema extends new ( - ...args: unknown[] -) => object - ? true +// prettier-ignore +type IsClassValidatorSchema = + TSchema extends new (...args: unknown[]) => object ? true : false; function isClassValidatorSchema( schema: SchemaFrom, @@ -41,23 +38,17 @@ function isClassValidatorSchema( ); } -type IsJSONSchema = TSchema extends {type: unknown} - ? true - : TSchema extends {const: unknown} - ? true - : TSchema extends {enum: unknown} - ? true - : TSchema extends {anyOf: unknown} - ? true - : TSchema extends {oneOf: unknown} - ? true - : TSchema extends {allOf: unknown} - ? true - : TSchema extends {not: unknown} - ? true - : TSchema extends {if: unknown} - ? true - : false; +// prettier-ignore +type IsJSONSchema = + TSchema extends {type: unknown} ? true + : TSchema extends {const: unknown} ? true + : TSchema extends {enum: unknown} ? true + : TSchema extends {anyOf: unknown} ? true + : TSchema extends {oneOf: unknown} ? true + : TSchema extends {allOf: unknown} ? true + : TSchema extends {not: unknown} ? true + : TSchema extends {if: unknown} ? true + : false; function isJSONSchema( schema: SchemaFrom, ): schema is SchemaFrom { @@ -80,43 +71,30 @@ function notJSON( return schema as any; } +// prettier-ignore export type Select = // eslint-disable-next-line @typescript-eslint/ban-types TSchema extends Function - ? TSchema extends {assert: unknown} - ? 'arktype' - : IsClassValidatorSchema extends true - ? 'classValidator' - : 'function' - : IsTypeboxSchema extends true - ? 'typebox' - : IsSuretypeSchema extends true - ? 'suretype' - : TSchema extends {__isYupSchema__: unknown} - ? 'yup' - : TSchema extends {_def: unknown} - ? 'zod' - : TSchema extends {async: unknown} - ? 'valibot' - : TSchema extends {refiner: unknown} - ? 'superstruct' - : TSchema extends {_flags: unknown} - ? 'joi' - : TSchema extends {encode: unknown} - ? 'ioTs' - : TSchema extends {reflect: unknown} - ? 'runtypes' - : TSchema extends {ast: unknown} - ? 'effect' - : TSchema extends {kind: unknown} - ? 'deepkit' - : TSchema extends {addValidator: unknown} - ? 'ow' - : TSchema extends {toTerminals: unknown} - ? 'valita' - : IsJSONSchema extends true - ? 'json' - : 'fastestValidator'; + ? TSchema extends {assert: unknown} ? 'arktype' + : IsClassValidatorSchema extends true ? 'classValidator' + : 'function' + : TSchema extends object + ? IsTypeboxSchema extends true ? 'typebox' + : IsSuretypeSchema extends true ? 'suretype' + : TSchema extends {__isYupSchema__: unknown} ? 'yup' + : TSchema extends {_def: unknown} ? 'zod' + : TSchema extends {async: unknown} ? 'valibot' + : TSchema extends {refiner: unknown} ? 'superstruct' + : TSchema extends {_flags: unknown} ? 'joi' + : TSchema extends {encode: unknown} ? 'ioTs' + : TSchema extends {reflect: unknown} ? 'runtypes' + : TSchema extends {ast: unknown} ? 'effect' + : TSchema extends {kind: unknown} ? 'deepkit' + : TSchema extends {addValidator: unknown} ? 'ow' + : TSchema extends {toTerminals: unknown} ? 'valita' + : IsJSONSchema extends true ? 'json' + : 'fastestValidator' + : never; export const select: < TMap extends {