@sinclair/typebox 0.24.50 → 0.24.51
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/package.json +1 -1
- package/typebox.d.ts +2 -2
- package/typebox.js +1 -1
package/package.json
CHANGED
package/typebox.d.ts
CHANGED
|
@@ -210,7 +210,7 @@ export interface TPromise<T extends TSchema = TSchema> extends TSchema {
|
|
|
210
210
|
type: 'promise';
|
|
211
211
|
item: TSchema;
|
|
212
212
|
}
|
|
213
|
-
export declare type TRecordKey = TString |
|
|
213
|
+
export declare type TRecordKey = TString | TNumeric | TUnion<TLiteral<any>[]>;
|
|
214
214
|
export interface TRecord<K extends TRecordKey = TRecordKey, T extends TSchema = TSchema> extends TSchema {
|
|
215
215
|
[Kind]: 'Record';
|
|
216
216
|
static: Record<Static<K>, Static<T, this['params']>>;
|
|
@@ -369,7 +369,7 @@ export declare class TypeBuilder {
|
|
|
369
369
|
/** Creates an object whose properties are derived from the given string literal union. */
|
|
370
370
|
Record<K extends TUnion<TLiteral[]>, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TObject<TRecordProperties<K, T>>;
|
|
371
371
|
/** Creates a record type */
|
|
372
|
-
Record<K extends TString |
|
|
372
|
+
Record<K extends TString | TNumeric, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TRecord<K, T>;
|
|
373
373
|
/** Creates a recursive object type */
|
|
374
374
|
Recursive<T extends TSchema>(callback: (self: TSelf) => T, options?: SchemaOptions): TRecursive<T>;
|
|
375
375
|
/** Creates a reference schema */
|
package/typebox.js
CHANGED
|
@@ -259,7 +259,7 @@ class TypeBuilder {
|
|
|
259
259
|
}, {}), { ...options, [exports.Hint]: 'Record' });
|
|
260
260
|
}
|
|
261
261
|
// otherwise return TRecord with patternProperties
|
|
262
|
-
const pattern = key[exports.Kind]
|
|
262
|
+
const pattern = ['Integer', 'Number'].includes(key[exports.Kind]) ? '^(0|[1-9][0-9]*)$' : key[exports.Kind] === 'String' && key.pattern ? key.pattern : '^.*$';
|
|
263
263
|
return this.Create({
|
|
264
264
|
...options,
|
|
265
265
|
[exports.Kind]: 'Record',
|