@sinclair/typebox
Advanced tools
Comparing version 0.20.4 to 0.20.5
{ | ||
"name": "@sinclair/typebox", | ||
"version": "0.20.4", | ||
"version": "0.20.5", | ||
"description": "JSONSchema Type Builder with Static Type Resolution for TypeScript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -41,3 +41,3 @@ <div align='center'> | ||
TypeBox is a library that creates in-memory JSON Schema objects that can be statically resolved to TypeScript types. The schemas produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox allows one to create a unified type that can be statically checked by the TypeScript compiler and runtime asserted using standard JSON Schema validation. | ||
TypeBox is a library that builds in-memory JSON Schema objects that can be statically resolved to TypeScript types. The schemas produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox allows one to create a unified type that can be statically checked by the TypeScript compiler and runtime asserted using standard JSON Schema validation. | ||
@@ -699,14 +699,14 @@ TypeBox can be used as a simple tool to build up complex schemas or integrated into RPC or REST services to help validate JSON data received over the wire. TypeBox does not provide any JSON schema validation. Please use libraries such as AJV to validate schemas built with this library. | ||
// | ||
// Common Types | ||
// Shared Types | ||
// | ||
//-------------------------------------------------------------------------------------------- | ||
const Common = Type.Box({ | ||
const Shared = Type.Box({ | ||
UserId: Type.String({ format: 'uuid' }), | ||
Email: Type.String({ format: 'email' }) | ||
}, { $id: 'Common' }) | ||
}, { $id: 'Shared' }) | ||
//-------------------------------------------------------------------------------------------- | ||
// | ||
// Setup AJV validator with the following options and formats | ||
// Setup Validator and Register Shared Types | ||
// | ||
@@ -718,3 +718,3 @@ //-------------------------------------------------------------------------------------------- | ||
.addKeyword('modifier') | ||
.addSchema(Common) // <-- Register Common Types | ||
.addSchema(Shared) // <-- Register Shared Types | ||
@@ -728,4 +728,4 @@ //-------------------------------------------------------------------------------------------- | ||
const User = Type.Object({ | ||
userId: Type.Ref(Common, 'UserId'), | ||
email: Type.Ref(Common, 'Email'), | ||
userId: Type.Ref(Shared, 'UserId'), | ||
email: Type.Ref(Shared, 'Email'), | ||
online: Type.Boolean() | ||
@@ -732,0 +732,0 @@ }, { additionalProperties: false }) |
@@ -199,9 +199,9 @@ export declare const ReadonlyOptionalModifier: unique symbol; | ||
export declare type ReadonlyOptionalPropertyKeys<T extends TProperties> = { | ||
[K in keyof T]: T[K] extends TReadonlyOptional<infer U> ? K : never; | ||
[K in keyof T]: T[K] extends TReadonlyOptional<TSchema> ? K : never; | ||
}[keyof T]; | ||
export declare type ReadonlyPropertyKeys<T extends TProperties> = { | ||
[K in keyof T]: T[K] extends TReadonly<infer U> ? K : never; | ||
[K in keyof T]: T[K] extends TReadonly<TSchema> ? K : never; | ||
}[keyof T]; | ||
export declare type OptionalPropertyKeys<T extends TProperties> = { | ||
[K in keyof T]: T[K] extends TOptional<infer U> ? K : never; | ||
[K in keyof T]: T[K] extends TOptional<TSchema> ? K : never; | ||
}[keyof T]; | ||
@@ -213,7 +213,7 @@ export declare type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>; | ||
export declare type StaticModifiers<T extends TProperties> = { | ||
readonly [K in ReadonlyOptionalPropertyKeys<T>]?: Static<T[K]>; | ||
readonly [K in ReadonlyOptionalPropertyKeys<T>]?: T[K] extends TReadonlyOptional<infer U> ? Static<U> : never; | ||
} & { | ||
readonly [K in ReadonlyPropertyKeys<T>]: Static<T[K]>; | ||
readonly [K in ReadonlyPropertyKeys<T>]: T[K] extends TReadonly<infer U> ? Static<U> : never; | ||
} & { | ||
[K in OptionalPropertyKeys<T>]?: Static<T[K]>; | ||
[K in OptionalPropertyKeys<T>]?: T[K] extends TOptional<infer U> ? Static<U> : never; | ||
} & { | ||
@@ -220,0 +220,0 @@ [K in RequiredPropertyKeys<T>]: Static<T[K]>; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88583