@sinclair/typebox 0.31.15 → 0.31.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/compiler.js +1 -1
- package/package.json +1 -1
- package/readme.md +1 -0
- package/typebox.d.ts +2 -2
package/compiler/compiler.js
CHANGED
|
@@ -228,7 +228,7 @@ var TypeCompiler;
|
|
|
228
228
|
const checkExpression = CreateExpression(containsSchema, references, 'value');
|
|
229
229
|
const checkMinContains = (0, guard_1.IsNumber)(schema.minContains) ? [`(count >= ${schema.minContains})`] : [];
|
|
230
230
|
const checkMaxContains = (0, guard_1.IsNumber)(schema.maxContains) ? [`(count <= ${schema.maxContains})`] : [];
|
|
231
|
-
const checkCount = `const count =
|
|
231
|
+
const checkCount = `const count = value.reduce((${accumulator}, ${parameter}) => ${checkExpression} ? acc + 1 : acc, 0)`;
|
|
232
232
|
const check = [`(count > 0)`, ...checkMinContains, ...checkMaxContains].join(' && ');
|
|
233
233
|
yield `((${parameter}) => { ${checkCount}; return ${check}})(${value})`;
|
|
234
234
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1608,6 +1608,7 @@ The following is a list of community packages that offer general tooling, extend
|
|
|
1608
1608
|
| [feathersjs](https://github.com/feathersjs/feathers) | The API and real-time application framework |
|
|
1609
1609
|
| [fetch-typebox](https://github.com/erfanium/fetch-typebox) | Drop-in replacement for fetch that brings easy integration with TypeBox |
|
|
1610
1610
|
| [h3-typebox](https://github.com/kevinmarrec/h3-typebox) | Schema validation utilities for h3 using TypeBox & Ajv |
|
|
1611
|
+
| [openapi-box](https://github.com/geut/openapi-box) | Generate TypeBox types from OpenApi IDL + Http client library |
|
|
1611
1612
|
| [schema2typebox](https://github.com/xddq/schema2typebox) | Creating TypeBox code from Json Schemas |
|
|
1612
1613
|
| [ts2typebox](https://github.com/xddq/ts2typebox) | Creating TypeBox code from Typescript types |
|
|
1613
1614
|
| [typebox-client](https://github.com/flodlc/typebox-client) | Type safe http client library for Fastify |
|
package/typebox.d.ts
CHANGED
|
@@ -339,11 +339,11 @@ export type TRecordFromUnionLiteralNumber<K extends TLiteralNumber, T extends TS
|
|
|
339
339
|
};
|
|
340
340
|
export type TRecordFromUnionRest<K extends TSchema[], T extends TSchema> = K extends [infer L, ...infer R] ? (L extends TUnion<infer S> ? TRecordFromUnionRest<S, T> & TRecordFromUnionRest<AssertRest<R>, T> : L extends TLiteralString ? TRecordFromUnionLiteralString<L, T> & TRecordFromUnionRest<AssertRest<R>, T> : L extends TLiteralNumber ? TRecordFromUnionLiteralNumber<L, T> & TRecordFromUnionRest<AssertRest<R>, T> : {}) : {};
|
|
341
341
|
export type TRecordFromUnion<K extends TSchema[], T extends TSchema> = Ensure<TObject<AssertProperties<Evaluate<TRecordFromUnionRest<K, T>>>>>;
|
|
342
|
-
export type TRecordFromTemplateLiteralKeyInfinite<T extends TSchema> = Ensure<TRecord<
|
|
342
|
+
export type TRecordFromTemplateLiteralKeyInfinite<K extends TTemplateLiteral, T extends TSchema> = Ensure<TRecord<K, T>>;
|
|
343
343
|
export type TRecordFromTemplateLiteralKeyFinite<K extends TTemplateLiteral, T extends TSchema, I = Static<K>> = Ensure<TObject<Evaluate<{
|
|
344
344
|
[_ in Assert<I, string>]: T;
|
|
345
345
|
}>>>;
|
|
346
|
-
export type TRecordFromTemplateLiteralKey<K extends TTemplateLiteral, T extends TSchema> = IsTemplateLiteralFinite<K> extends false ? TRecordFromTemplateLiteralKeyInfinite<T> : TRecordFromTemplateLiteralKeyFinite<K, T>;
|
|
346
|
+
export type TRecordFromTemplateLiteralKey<K extends TTemplateLiteral, T extends TSchema> = IsTemplateLiteralFinite<K> extends false ? TRecordFromTemplateLiteralKeyInfinite<K, T> : TRecordFromTemplateLiteralKeyFinite<K, T>;
|
|
347
347
|
export type TRecordFromLiteralStringKey<K extends TLiteralString, T extends TSchema> = Ensure<TObject<{
|
|
348
348
|
[_ in K['const']]: T;
|
|
349
349
|
}>>;
|