typebox 1.2.0 → 1.2.1
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.
|
@@ -309,8 +309,8 @@ export type TPatternBigIntMapping<Input extends '-?(?:0|[1-9][0-9]*)n'> = (T.TBi
|
|
|
309
309
|
export declare function PatternBigIntMapping(input: '-?(?:0|[1-9][0-9]*)n'): unknown;
|
|
310
310
|
export type TPatternStringMapping<Input extends '.*'> = (T.TString);
|
|
311
311
|
export declare function PatternStringMapping(input: '.*'): unknown;
|
|
312
|
-
export type TPatternNumberMapping<Input extends '-?(?:0|[1-9][0-9]*)(
|
|
313
|
-
export declare function PatternNumberMapping(input: '-?(?:0|[1-9][0-9]*)(
|
|
312
|
+
export type TPatternNumberMapping<Input extends '-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?'> = (T.TNumber);
|
|
313
|
+
export declare function PatternNumberMapping(input: '-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?'): unknown;
|
|
314
314
|
export type TPatternIntegerMapping<Input extends '-?(?:0|[1-9][0-9]*)'> = (T.TInteger);
|
|
315
315
|
export declare function PatternIntegerMapping(input: '-?(?:0|[1-9][0-9]*)'): unknown;
|
|
316
316
|
export type TPatternNeverMapping<Input extends '(?!)'> = (T.TNever);
|
|
@@ -106,10 +106,10 @@ export type TJsonArray<Input extends string> = (Token.TConst<'[', Input> extends
|
|
|
106
106
|
export type TJson<Input extends string> = (TJsonNumber<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TJsonBoolean<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TJsonString<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TJsonNull<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TJsonObject<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TJsonArray<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [S.TJsonMapping<_0>, Input] : [];
|
|
107
107
|
export type TPatternBigInt<Input extends string> = Token.TConst<'-?(?:0|[1-9][0-9]*)n', Input> extends [infer _0 extends '-?(?:0|[1-9][0-9]*)n', infer Input extends string] ? [S.TPatternBigIntMapping<_0>, Input] : [];
|
|
108
108
|
export type TPatternString<Input extends string> = Token.TConst<'.*', Input> extends [infer _0 extends '.*', infer Input extends string] ? [S.TPatternStringMapping<_0>, Input] : [];
|
|
109
|
-
export type TPatternNumber<Input extends string> = Token.TConst<'-?(?:0|[1-9][0-9]*)(
|
|
109
|
+
export type TPatternNumber<Input extends string> = Token.TConst<'-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?', Input> extends [infer _0 extends '-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?', infer Input extends string] ? [S.TPatternNumberMapping<_0>, Input] : [];
|
|
110
110
|
export type TPatternInteger<Input extends string> = Token.TConst<'-?(?:0|[1-9][0-9]*)', Input> extends [infer _0 extends '-?(?:0|[1-9][0-9]*)', infer Input extends string] ? [S.TPatternIntegerMapping<_0>, Input] : [];
|
|
111
111
|
export type TPatternNever<Input extends string> = Token.TConst<'(?!)', Input> extends [infer _0 extends '(?!)', infer Input extends string] ? [S.TPatternNeverMapping<_0>, Input] : [];
|
|
112
|
-
export type TPatternText<Input extends string> = Token.TUntil_1<['-?(?:0|[1-9][0-9]*)n', '.*', '-?(?:0|[1-9][0-9]*)(
|
|
112
|
+
export type TPatternText<Input extends string> = Token.TUntil_1<['-?(?:0|[1-9][0-9]*)n', '.*', '-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?', '-?(?:0|[1-9][0-9]*)', '(?!)', '(', ')', '$', '|'], Input> extends [infer _0 extends string, infer Input extends string] ? [S.TPatternTextMapping<_0>, Input] : [];
|
|
113
113
|
export type TPatternBase<Input extends string> = (TPatternBigInt<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternString<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternNumber<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternInteger<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternNever<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternGroup<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternText<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [S.TPatternBaseMapping<_0>, Input] : [];
|
|
114
114
|
export type TPatternGroup<Input extends string> = (Token.TConst<'(', Input> extends [infer _0, infer Input extends string] ? (TPatternBody<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<')', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TPatternGroupMapping<_0>, Input] : [];
|
|
115
115
|
export type TPatternUnion<Input extends string> = ((TPatternTerm<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'|', Input> extends [infer _1, infer Input extends string] ? (TPatternUnion<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (TPatternTerm<Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [unknown] | [], infer Input extends string] ? [S.TPatternUnionMapping<_0>, Input] : [];
|
|
@@ -110,10 +110,10 @@ export const JsonArray = (input) => If(If(Token.Const('[', input), ([_0, input])
|
|
|
110
110
|
export const Json = (input) => If(If(JsonNumber(input), ([_0, input]) => [_0, input], () => If(JsonBoolean(input), ([_0, input]) => [_0, input], () => If(JsonString(input), ([_0, input]) => [_0, input], () => If(JsonNull(input), ([_0, input]) => [_0, input], () => If(JsonObject(input), ([_0, input]) => [_0, input], () => If(JsonArray(input), ([_0, input]) => [_0, input], () => [])))))), ([_0, input]) => [S.JsonMapping(_0), input]);
|
|
111
111
|
export const PatternBigInt = (input) => If(Token.Const('-?(?:0|[1-9][0-9]*)n', input), ([_0, input]) => [S.PatternBigIntMapping(_0), input]);
|
|
112
112
|
export const PatternString = (input) => If(Token.Const('.*', input), ([_0, input]) => [S.PatternStringMapping(_0), input]);
|
|
113
|
-
export const PatternNumber = (input) => If(Token.Const('-?(?:0|[1-9][0-9]*)(
|
|
113
|
+
export const PatternNumber = (input) => If(Token.Const('-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?', input), ([_0, input]) => [S.PatternNumberMapping(_0), input]);
|
|
114
114
|
export const PatternInteger = (input) => If(Token.Const('-?(?:0|[1-9][0-9]*)', input), ([_0, input]) => [S.PatternIntegerMapping(_0), input]);
|
|
115
115
|
export const PatternNever = (input) => If(Token.Const('(?!)', input), ([_0, input]) => [S.PatternNeverMapping(_0), input]);
|
|
116
|
-
export const PatternText = (input) => If(Token.Until_1(['-?(?:0|[1-9][0-9]*)n', '.*', '-?(?:0|[1-9][0-9]*)(
|
|
116
|
+
export const PatternText = (input) => If(Token.Until_1(['-?(?:0|[1-9][0-9]*)n', '.*', '-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?', '-?(?:0|[1-9][0-9]*)', '(?!)', '(', ')', '$', '|'], input), ([_0, input]) => [S.PatternTextMapping(_0), input]);
|
|
117
117
|
export const PatternBase = (input) => If(If(PatternBigInt(input), ([_0, input]) => [_0, input], () => If(PatternString(input), ([_0, input]) => [_0, input], () => If(PatternNumber(input), ([_0, input]) => [_0, input], () => If(PatternInteger(input), ([_0, input]) => [_0, input], () => If(PatternNever(input), ([_0, input]) => [_0, input], () => If(PatternGroup(input), ([_0, input]) => [_0, input], () => If(PatternText(input), ([_0, input]) => [_0, input], () => []))))))), ([_0, input]) => [S.PatternBaseMapping(_0), input]);
|
|
118
118
|
export const PatternGroup = (input) => If(If(Token.Const('(', input), ([_0, input]) => If(PatternBody(input), ([_1, input]) => If(Token.Const(')', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.PatternGroupMapping(_0), input]);
|
|
119
119
|
export const PatternUnion = (input) => If(If(If(PatternTerm(input), ([_0, input]) => If(Token.Const('|', input), ([_1, input]) => If(PatternUnion(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(If(PatternTerm(input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => []))), ([_0, input]) => [S.PatternUnionMapping(_0), input]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type TSchema, type TNumberOptions } from './schema.mjs';
|
|
2
|
-
export declare const NumberPattern = "-?(?:0|[1-9][0-9]*)(
|
|
2
|
+
export declare const NumberPattern = "-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";
|
|
3
3
|
export type StaticNumber = number;
|
|
4
4
|
/** Represents a Number type. */
|
|
5
5
|
export interface TNumber extends TSchema {
|
|
@@ -4,7 +4,7 @@ import { IsKind } from './schema.mjs';
|
|
|
4
4
|
// ------------------------------------------------------------------
|
|
5
5
|
// Pattern
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
|
-
export const NumberPattern = '-?(?:0|[1-9][0-9]*)(
|
|
7
|
+
export const NumberPattern = '-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?';
|
|
8
8
|
// ------------------------------------------------------------------
|
|
9
9
|
// Factory
|
|
10
10
|
// ------------------------------------------------------------------
|
|
@@ -14,7 +14,7 @@ export type TStringKey = typeof StringKey;
|
|
|
14
14
|
export type TIntegerKey = typeof IntegerKey;
|
|
15
15
|
export type TNumberKey = typeof NumberKey;
|
|
16
16
|
export declare const IntegerKey = "^-?(?:0|[1-9][0-9]*)$";
|
|
17
|
-
export declare const NumberKey = "^-?(?:0|[1-9][0-9]*)(
|
|
17
|
+
export declare const NumberKey = "^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$";
|
|
18
18
|
export declare const StringKey = "^.*$";
|
|
19
19
|
export interface TRecord<Key extends string = string, Value extends TSchema = TSchema> extends TSchema {
|
|
20
20
|
'~kind': 'Record';
|