|
5 | 5 | BooleanSchema,
|
6 | 6 | CustomSchema,
|
7 | 7 | DateSchema,
|
8 |
| - MappedObjectKeySchemas, |
9 |
| - MappedObjectSchema, |
| 8 | + LiteralObjectKeySchemas, |
| 9 | + LiteralObjectSchema, |
10 | 10 | NumberSchema,
|
11 | 11 | ObjectSchema,
|
12 | 12 | OrSchema,
|
@@ -68,15 +68,15 @@ export function value<T extends string | number | boolean | null | undefined>(va
|
68 | 68 | * @param fields The object and nested validation schemas the value must match.
|
69 | 69 | * @param requiredMessage The error to return if the value is undefined.
|
70 | 70 | */
|
71 |
| -export function object<T>(fields: MappedObjectKeySchemas<T>, requiredMessage?: string): MappedObjectSchema<T>; |
| 71 | +export function object<T>(fields: LiteralObjectKeySchemas<T>, requiredMessage?: string): LiteralObjectSchema<T>; |
72 | 72 | /**
|
73 | 73 | * Requires this field to be a object, allowing all keys and values.
|
74 | 74 | * @param requiredMessage The error to return if the value is undefined.
|
75 | 75 | */
|
76 | 76 | export function object<T>(requiredMessage?: string): ObjectSchema;
|
77 | 77 | export function object() {
|
78 | 78 | if (typeof arguments[0] === "object") {
|
79 |
| - return new MappedObjectSchema(arguments[0], arguments[1]); |
| 79 | + return new LiteralObjectSchema(arguments[0], arguments[1]); |
80 | 80 | } else {
|
81 | 81 | return new ObjectSchema(arguments[0] ?? arguments[1]);
|
82 | 82 | }
|
@@ -143,6 +143,11 @@ export function any(requiredMessage?: string) {
|
143 | 143 | return new AnySchema(requiredMessage);
|
144 | 144 | }
|
145 | 145 |
|
| 146 | +/** |
| 147 | + * Requires this field to be a mapped object type. |
| 148 | + * @param keySchema The keys of the object must match this schema. |
| 149 | + * @param valueSchema The values of the object must match this schema. |
| 150 | + */ |
146 | 151 | export function mapped<K extends string | number | symbol, V>(keySchema: Schema<K>, valueSchema: Schema<V>): MappedSchema<K, V> {
|
147 | 152 | return new MappedSchema(keySchema, valueSchema);
|
148 | 153 | }
|
0 commit comments