@orion-js/schema 4.3.1 → 4.4.0
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/LICENSE +21 -0
- package/dist/Errors.d.ts +21 -0
- package/dist/ValidationError.d.ts +16 -0
- package/dist/clean/cleanType.d.ts +3 -0
- package/dist/clean/getObjectNode.d.ts +2 -0
- package/dist/clean/index.d.ts +3 -0
- package/dist/clean/recursiveClean.d.ts +3 -0
- package/dist/cleanAndValidate.d.ts +2 -0
- package/dist/cleanKey.d.ts +1 -0
- package/dist/clone.d.ts +1 -0
- package/dist/cloneSchema.d.ts +35 -0
- package/dist/dotGetSchema.d.ts +2 -0
- package/dist/fieldType.d.ts +19 -0
- package/dist/fieldTypes/ID.d.ts +2 -0
- package/dist/fieldTypes/any.d.ts +2 -0
- package/dist/fieldTypes/array.d.ts +2 -0
- package/dist/fieldTypes/blackbox.d.ts +3 -0
- package/dist/fieldTypes/boolean.d.ts +2 -0
- package/dist/fieldTypes/date.d.ts +2 -0
- package/dist/fieldTypes/email.d.ts +2 -0
- package/dist/fieldTypes/enum.d.ts +2 -0
- package/dist/fieldTypes/index.d.ts +14 -0
- package/dist/fieldTypes/integer.d.ts +2 -0
- package/dist/fieldTypes/number.d.ts +2 -0
- package/dist/fieldTypes/plainObject.d.ts +3 -0
- package/dist/fieldTypes/string.d.ts +2 -0
- package/dist/getValidationErrors/convertTypedSchema.d.ts +2 -0
- package/dist/getValidationErrors/doValidation.d.ts +2 -0
- package/dist/getValidationErrors/getError/getFieldType.d.ts +4 -0
- package/dist/getValidationErrors/getError/getFieldValidator.d.ts +3 -0
- package/dist/getValidationErrors/getError/index.d.ts +2 -0
- package/dist/getValidationErrors/getFieldLabels.d.ts +6 -0
- package/dist/getValidationErrors/getValidationErrorsObject.d.ts +4 -0
- package/dist/getValidationErrors/index.d.ts +3 -0
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +18 -304
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/isValid.d.ts +3 -0
- package/dist/models.d.ts +7 -0
- package/dist/schemaWithName/index.d.ts +15 -0
- package/dist/types/fieldValidators.d.ts +2 -0
- package/dist/types/fields.d.ts +37 -0
- package/dist/types/helpers.d.ts +2 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/schema.d.ts +145 -0
- package/dist/validate.d.ts +3 -0
- package/dist/validateKey/dotGetSchema.d.ts +2 -0
- package/dist/validateKey/index.d.ts +2 -0
- package/package.json +10 -11
- package/dist/index.d.cts +0 -304
package/dist/index.d.ts
CHANGED
|
@@ -1,304 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
type SchemaNode<TFieldType extends SchemaFieldType = SchemaFieldType> = {
|
|
21
|
-
/**
|
|
22
|
-
* The type of the field. Used for type validations. Can also contain a subschema.
|
|
23
|
-
*/
|
|
24
|
-
type: TFieldType;
|
|
25
|
-
/**
|
|
26
|
-
* Defaults to false
|
|
27
|
-
*/
|
|
28
|
-
optional?: boolean;
|
|
29
|
-
allowedValues?: Array<InferSchemaType<TFieldType>>;
|
|
30
|
-
defaultValue?: ((info: CurrentNodeInfo, ...args: any[]) => InferSchemaType<TFieldType> | Promise<InferSchemaType<TFieldType>>) | InferSchemaType<TFieldType>;
|
|
31
|
-
/**
|
|
32
|
-
* Function that takes a value and returns an error message if there are any errors. Must return null or undefined otherwise.
|
|
33
|
-
*/
|
|
34
|
-
validate?: ValidateFunction<InferSchemaType<TFieldType>>;
|
|
35
|
-
/**
|
|
36
|
-
* Function that preprocesses a value before it is set.
|
|
37
|
-
*/
|
|
38
|
-
clean?: CleanFunction<InferSchemaType<TFieldType>>;
|
|
39
|
-
/**
|
|
40
|
-
* The minimum value if it's a number, the minimum length if it's a string or array.
|
|
41
|
-
*/
|
|
42
|
-
min?: number;
|
|
43
|
-
/**
|
|
44
|
-
* The maximum value if it's a number, the maximum length if it's a string or array.
|
|
45
|
-
*/
|
|
46
|
-
max?: number;
|
|
47
|
-
/**
|
|
48
|
-
* Internal use only.
|
|
49
|
-
*/
|
|
50
|
-
isBlackboxChild?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Used in GraphQL. If true, the field will be omitted from the schema.
|
|
53
|
-
*/
|
|
54
|
-
private?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Used in GraphQL. When in GraphQL, this resolver will replace the static field.
|
|
57
|
-
*/
|
|
58
|
-
graphQLResolver?: (...args: any) => any;
|
|
59
|
-
/**
|
|
60
|
-
* Used in GraphQL. Sets the key of the field in the GraphQL schema. You must set this value when building your schema.
|
|
61
|
-
*/
|
|
62
|
-
key?: string;
|
|
63
|
-
/**
|
|
64
|
-
* The name that would be displayed in a front-end form
|
|
65
|
-
*/
|
|
66
|
-
label?: string;
|
|
67
|
-
/**
|
|
68
|
-
* The description that would be displayed in a front-end form
|
|
69
|
-
*/
|
|
70
|
-
description?: string;
|
|
71
|
-
/**
|
|
72
|
-
* The placeholder that would be displayed in a front-end form
|
|
73
|
-
*/
|
|
74
|
-
placeholder?: string;
|
|
75
|
-
/**
|
|
76
|
-
* The field type that would be used in a front-end form
|
|
77
|
-
*/
|
|
78
|
-
fieldType?: string;
|
|
79
|
-
/**
|
|
80
|
-
* The field options that will be passed as props to the front-end field
|
|
81
|
-
*/
|
|
82
|
-
fieldOptions?: any;
|
|
83
|
-
} & SchemaRecursiveNodeTypeExtras;
|
|
84
|
-
interface CurrentNodeInfoOptions {
|
|
85
|
-
autoConvert?: boolean;
|
|
86
|
-
filter?: boolean;
|
|
87
|
-
trimStrings?: boolean;
|
|
88
|
-
removeEmptyStrings?: boolean;
|
|
89
|
-
forceDoc?: any;
|
|
90
|
-
omitRequired?: boolean;
|
|
91
|
-
}
|
|
92
|
-
interface CurrentNodeInfo {
|
|
93
|
-
/**
|
|
94
|
-
* The global schema, prefaced by {type: {...}} to be compatible with subschemas
|
|
95
|
-
* Sometimes it's given without {type: {...}}. TODO: Normalize this.
|
|
96
|
-
*/
|
|
97
|
-
schema?: SchemaFieldType;
|
|
98
|
-
/**
|
|
99
|
-
* The current node subschema
|
|
100
|
-
*/
|
|
101
|
-
currentSchema?: Partial<SchemaNode<SchemaFieldType>>;
|
|
102
|
-
value: InferSchemaType<SchemaFieldType>;
|
|
103
|
-
doc?: any;
|
|
104
|
-
currentDoc?: any;
|
|
105
|
-
options?: CurrentNodeInfoOptions;
|
|
106
|
-
args?: any[];
|
|
107
|
-
type?: SchemaFieldType;
|
|
108
|
-
keys?: string[];
|
|
109
|
-
addError?: (keys: string[], code: string | object) => void;
|
|
110
|
-
}
|
|
111
|
-
type SchemaMetadata = {
|
|
112
|
-
/**
|
|
113
|
-
* The name of the model (to make it compatible with GraphQL)
|
|
114
|
-
*/
|
|
115
|
-
__modelName?: string;
|
|
116
|
-
/**
|
|
117
|
-
* Cleans the whole schema
|
|
118
|
-
*/
|
|
119
|
-
__clean?: CleanFunction;
|
|
120
|
-
/**
|
|
121
|
-
* Validates the whole schema
|
|
122
|
-
*/
|
|
123
|
-
__validate?: ValidateFunction;
|
|
124
|
-
/**
|
|
125
|
-
* The resolvers of the model
|
|
126
|
-
*/
|
|
127
|
-
__resolvers?: any;
|
|
128
|
-
};
|
|
129
|
-
type Schema = {
|
|
130
|
-
[K: string]: SchemaNode;
|
|
131
|
-
};
|
|
132
|
-
type SingleLevelSchema = {
|
|
133
|
-
[K: string]: SchemaNode<SchemaFieldTypeNonSchema>;
|
|
134
|
-
};
|
|
135
|
-
type SchemaInAnyOrionForm = Schema | TypedSchemaOnSchema;
|
|
136
|
-
type SchemaWithMetadata = {
|
|
137
|
-
[K: string]: SchemaNode | SchemaMetadata[keyof SchemaMetadata];
|
|
138
|
-
} & SchemaMetadata;
|
|
139
|
-
|
|
140
|
-
interface FieldTypeOpts<TType = any> {
|
|
141
|
-
name: string;
|
|
142
|
-
validate?: ValidateFunction<TType>;
|
|
143
|
-
clean?: CleanFunction<TType>;
|
|
144
|
-
toGraphQLType?: (GraphQL: any) => any;
|
|
145
|
-
meta?: any;
|
|
146
|
-
}
|
|
147
|
-
interface FieldType<TType = any> {
|
|
148
|
-
name: string;
|
|
149
|
-
validate: ValidateFunction;
|
|
150
|
-
clean: CleanFunction;
|
|
151
|
-
meta?: any;
|
|
152
|
-
toGraphQLType?: (GraphQL: any) => any;
|
|
153
|
-
toSerializedType?: (node: SchemaNode) => Promise<SchemaFieldType>;
|
|
154
|
-
__tsFieldType: TType;
|
|
155
|
-
__isFieldType: boolean;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
type InferSchemaTypeForFieldType<T> = T extends {
|
|
159
|
-
__tsFieldType: infer U;
|
|
160
|
-
} ? U : T extends 'string' ? string : T extends 'date' ? Date : T extends 'integer' ? number : T extends 'number' ? number : T extends 'ID' ? string : T extends 'boolean' ? boolean : T extends 'email' ? string : T extends 'blackbox' ? Blackbox : T extends 'any' ? any : T extends String ? string : T extends Number ? number : T extends Boolean ? boolean : T extends Date ? Date : T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends DateConstructor ? Date : T extends Array<infer U> ? InferSchemaTypeForFieldType<U>[] : T extends Record<string, any> ? InferSchemaTypeForSchema<T> : T;
|
|
161
|
-
type SchemaKeysNotOfSchemaItems = '__isFieldType' | '__GraphQLType' | '__skipChildValidation';
|
|
162
|
-
type NodeIsOptional<TNode> = TNode extends {
|
|
163
|
-
optional: true;
|
|
164
|
-
} ? true : false;
|
|
165
|
-
type WithoutNotSchemaItems<T extends Record<string, any>> = T extends {
|
|
166
|
-
[key in SchemaKeysNotOfSchemaItems]: any;
|
|
167
|
-
} & Record<string, any> ? Omit<T, SchemaKeysNotOfSchemaItems> : T;
|
|
168
|
-
type InferSchemaTypeForSchema<TSchema extends Record<string, any>> = WithoutNotSchemaItems<{
|
|
169
|
-
-readonly [K in keyof TSchema as NodeIsOptional<TSchema[K]> extends true ? never : K]: InferSchemaType<TSchema[K]['type']>;
|
|
170
|
-
} & {
|
|
171
|
-
-readonly [K in keyof TSchema as NodeIsOptional<TSchema[K]> extends true ? K : never]?: InferSchemaType<TSchema[K]['type']>;
|
|
172
|
-
}>;
|
|
173
|
-
type IsPossiblyASchema<TType> = TType extends FieldType ? false : TType extends Record<string, any> ? keyof {
|
|
174
|
-
[K in keyof TType as 'type' extends keyof TType[K] ? K : never]: TType[K];
|
|
175
|
-
} extends never ? false : true : false;
|
|
176
|
-
type AClass<T = any> = abstract new (...args: any) => T;
|
|
177
|
-
/**
|
|
178
|
-
* Returns the type of the schema
|
|
179
|
-
*/
|
|
180
|
-
type InferSchemaType<TType> = TType extends {
|
|
181
|
-
__isModel: true;
|
|
182
|
-
type: infer U;
|
|
183
|
-
} ? InferSchemaTypeForSchema<U> : TType extends SchemaMetaFieldTypeSingleNonSchema ? InferSchemaTypeForFieldType<TType> : TType extends AClass<infer U> ? U : IsPossiblyASchema<TType> extends true ? InferSchemaTypeForSchema<TType> : InferSchemaTypeForFieldType<TType>;
|
|
184
|
-
/**
|
|
185
|
-
* Returns the type of the schema but only if its a schema
|
|
186
|
-
*/
|
|
187
|
-
type StrictInferSchemaType<TSchema extends Schema> = InferSchemaTypeForSchema<TSchema>;
|
|
188
|
-
/**
|
|
189
|
-
* Returns the type of the schema but only if its a schema
|
|
190
|
-
*/
|
|
191
|
-
type InferSchemaTypeFromTypedSchema<TTypedSchema extends TypedSchemaOnSchema> = TTypedSchema;
|
|
192
|
-
|
|
193
|
-
declare function validate<TSchema extends SchemaFieldType>(schema: TSchema, doc: InferSchemaType<TSchema>, passedOptions?: {}, ...args: any[]): Promise<void>;
|
|
194
|
-
|
|
195
|
-
interface ValidationErrorInfo {
|
|
196
|
-
error: string;
|
|
197
|
-
message: string;
|
|
198
|
-
validationErrors: Record<string, string>;
|
|
199
|
-
labels: Record<string, string>;
|
|
200
|
-
}
|
|
201
|
-
declare class ValidationError extends Error {
|
|
202
|
-
code: string;
|
|
203
|
-
isValidationError: boolean;
|
|
204
|
-
isOrionError: boolean;
|
|
205
|
-
validationErrors: Record<string, string>;
|
|
206
|
-
labels: Record<string, string>;
|
|
207
|
-
constructor(validationErrors: Record<string, string>, labels?: Record<string, string>);
|
|
208
|
-
getInfo: () => ValidationErrorInfo;
|
|
209
|
-
prependKey: (prepend: any) => ValidationError;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
declare const _default: {
|
|
213
|
-
array: FieldType<any[]>;
|
|
214
|
-
plainObject: FieldType<Blackbox>;
|
|
215
|
-
string: FieldType<string>;
|
|
216
|
-
date: FieldType<Date>;
|
|
217
|
-
integer: FieldType<number>;
|
|
218
|
-
number: FieldType<number>;
|
|
219
|
-
ID: FieldType<string>;
|
|
220
|
-
boolean: FieldType<boolean>;
|
|
221
|
-
email: FieldType<string>;
|
|
222
|
-
blackbox: FieldType<Blackbox>;
|
|
223
|
-
any: FieldType<any>;
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
type FieldValidatorType = keyof typeof _default | 'custom' | 'plainObject';
|
|
227
|
-
|
|
228
|
-
type MergeSchemas<SchemaA extends Schema, SchemaB extends Schema> = SchemaA & SchemaB;
|
|
229
|
-
|
|
230
|
-
declare function getValidationErrors<TSchema extends SchemaFieldType>(schema: TSchema, doc: InferSchemaType<TSchema>, passedOptions?: {}, ...args: any[]): Promise<any>;
|
|
231
|
-
|
|
232
|
-
declare function isValid<TSchema extends Schema>(schema: TSchema, doc: InferSchemaType<TSchema>, passedOptions?: {}, ...args: any[]): Promise<boolean>;
|
|
233
|
-
|
|
234
|
-
declare function getFieldType(type: SchemaFieldType | FieldValidatorType | any): FieldType;
|
|
235
|
-
|
|
236
|
-
declare function clean<TSchema extends SchemaFieldType>(schema: TSchema, doc: InferSchemaType<TSchema>, opts?: CurrentNodeInfoOptions, ...args: any[]): Promise<InferSchemaType<TSchema>>;
|
|
237
|
-
|
|
238
|
-
declare function export_default$2(schema: any, key: any, value: any, passedOptions?: {}, ...args: any[]): Promise<any>;
|
|
239
|
-
|
|
240
|
-
declare function export_default$1(schema: Schema, key: string, value: any, passedOptions?: CurrentNodeInfoOptions, ...args: any[]): Promise<any>;
|
|
241
|
-
|
|
242
|
-
declare function export_default(schema: Schema, path: string): SchemaNode;
|
|
243
|
-
|
|
244
|
-
declare function createEnum<const TValues extends readonly string[]>(name: string, values: TValues): FieldType<TValues[number]>;
|
|
245
|
-
|
|
246
|
-
declare function isSchemaLike(type: any): boolean;
|
|
247
|
-
declare function isStrictSchemaLike<TType extends Schema | SchemaFieldTypeNonSchema>(type: TType): TType extends Schema ? true : false;
|
|
248
|
-
declare function isSchemaOrFieldLike(type: any): boolean;
|
|
249
|
-
declare function getSchemaModelName(type: any): string | null;
|
|
250
|
-
declare function getSchemaFromAnyOrionForm(type: any): SchemaFieldType;
|
|
251
|
-
declare function getSchemaWithMetadataFromAnyOrionForm(type: any): SchemaWithMetadata;
|
|
252
|
-
|
|
253
|
-
declare function cleanAndValidate<TSchema extends SchemaFieldType>(schema: TSchema, doc: InferSchemaType<TSchema>): Promise<InferSchemaType<TSchema>>;
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Assigns a name to a schema for GraphQL type generation.
|
|
257
|
-
*
|
|
258
|
-
* This function associates a name with a schema object by setting an internal
|
|
259
|
-
* `__modelName` property. This name is used when generating GraphQL types.
|
|
260
|
-
*
|
|
261
|
-
* @param name - The name to assign to the schema
|
|
262
|
-
* @param schema - The schema object to name
|
|
263
|
-
* @returns The same schema object with the internal name property added
|
|
264
|
-
*
|
|
265
|
-
* Note: The schema object is modified in-place, so the name will persist
|
|
266
|
-
* even if you don't use the returned value.
|
|
267
|
-
*/
|
|
268
|
-
declare function schemaWithName<TModelName extends string, TSchema extends Schema>(name: TModelName, schema: TSchema): TSchema;
|
|
269
|
-
|
|
270
|
-
type CloneSchemaOptions<TSchema extends Schema, TExtendFields extends Schema | undefined = undefined, TPickFields extends (keyof TSchema)[] | undefined = undefined, TOmitFields extends (keyof TSchema)[] | undefined = undefined> = {
|
|
271
|
-
/**
|
|
272
|
-
* The schema to clone
|
|
273
|
-
*/
|
|
274
|
-
schema: TSchema;
|
|
275
|
-
/**
|
|
276
|
-
* The name of the cloned schema
|
|
277
|
-
*/
|
|
278
|
-
name?: string;
|
|
279
|
-
/**
|
|
280
|
-
* The schema to extend the cloned schema with
|
|
281
|
-
*/
|
|
282
|
-
extendSchema?: TExtendFields;
|
|
283
|
-
/**
|
|
284
|
-
* A function to map the fields of the cloned schema.
|
|
285
|
-
* Warning: This function will not be applied to the typescript types of this schema.
|
|
286
|
-
*/
|
|
287
|
-
mapFields?: (field: TSchema[keyof TSchema], key: keyof TSchema) => SchemaNode;
|
|
288
|
-
/**
|
|
289
|
-
* The fields to pick from the cloned schema
|
|
290
|
-
*/
|
|
291
|
-
pickFields?: TPickFields;
|
|
292
|
-
/**
|
|
293
|
-
* The fields to omit from the cloned schema
|
|
294
|
-
*/
|
|
295
|
-
omitFields?: TOmitFields;
|
|
296
|
-
};
|
|
297
|
-
type ExtendFields<TSchema extends Schema, TExtendFields extends Schema | undefined> = TExtendFields extends undefined ? TSchema : {
|
|
298
|
-
[key in keyof (TSchema & TExtendFields)]: key extends keyof TExtendFields ? TExtendFields[key] : key extends keyof TSchema ? TSchema[key] : never;
|
|
299
|
-
};
|
|
300
|
-
type PickOrOmit<TSchema extends Schema, TPickFields extends (keyof TSchema)[] | undefined = undefined, TOmitFields extends (keyof TSchema)[] | undefined = undefined> = TPickFields extends undefined ? TOmitFields extends undefined ? TSchema : Omit<TSchema, TOmitFields[number]> : Pick<TSchema, TPickFields[number]>;
|
|
301
|
-
type ClonedSchema<TSchema extends Schema, TExtendFields extends Schema | undefined = undefined, TPickFields extends (keyof TSchema)[] | undefined = undefined, TOmitFields extends (keyof TSchema)[] | undefined = undefined> = ExtendFields<PickOrOmit<TSchema, TPickFields, TOmitFields>, TExtendFields>;
|
|
302
|
-
declare function cloneSchema<TSchema extends Schema, TExtendFields extends Schema | undefined = undefined, TPickFields extends (keyof TSchema)[] | undefined = undefined, TOmitFields extends (keyof TSchema)[] | undefined = undefined>(options: CloneSchemaOptions<TSchema, TExtendFields, TPickFields, TOmitFields>): ClonedSchema<TSchema, TExtendFields, TPickFields, TOmitFields>;
|
|
303
|
-
|
|
304
|
-
export { type Blackbox, type CleanFunction, type CloneSchemaOptions, type ClonedSchema, type Constructor, type ConstructorsTypesList, type CurrentNodeInfo, type CurrentNodeInfoOptions, type FieldType, type FieldTypeOpts, type FieldTypesList, type FieldValidatorType, type InferSchemaType, type InferSchemaTypeFromTypedSchema, type MergeSchemas, type Schema, type SchemaFieldType, type SchemaFieldTypeNonSchema, type SchemaInAnyOrionForm, type SchemaMetaFieldTypeSingle, type SchemaMetaFieldTypeSingleNonSchema, type SchemaMetadata, type SchemaNode, type SchemaRecursiveNodeTypeExtras, type SchemaWithMetadata, type SingleLevelSchema, type StrictInferSchemaType, type TypedSchemaOnSchema, type ValidateFunction, ValidationError, clean, cleanAndValidate, export_default$2 as cleanKey, cloneSchema, createEnum, export_default as dotGetSchema, _default as fieldTypes, getFieldType, getSchemaFromAnyOrionForm, getSchemaModelName, getSchemaWithMetadataFromAnyOrionForm, getValidationErrors, isSchemaLike, isSchemaOrFieldLike, isStrictSchemaLike, isValid, schemaWithName, validate, export_default$1 as validateKey };
|
|
1
|
+
import validate from './validate';
|
|
2
|
+
import ValidationError from './ValidationError';
|
|
3
|
+
import getValidationErrors from './getValidationErrors';
|
|
4
|
+
import isValid from './isValid';
|
|
5
|
+
import getFieldType from './getValidationErrors/getError/getFieldType';
|
|
6
|
+
import clean from './clean';
|
|
7
|
+
import cleanKey from './cleanKey';
|
|
8
|
+
import validateKey from './validateKey';
|
|
9
|
+
import dotGetSchema from './dotGetSchema';
|
|
10
|
+
import createEnum from './fieldTypes/enum';
|
|
11
|
+
import fieldTypes from './fieldTypes';
|
|
12
|
+
export { validate, ValidationError, getValidationErrors, isValid, getFieldType, clean, cleanKey, dotGetSchema, validateKey, createEnum, fieldTypes, };
|
|
13
|
+
export * from './types';
|
|
14
|
+
export * from './models';
|
|
15
|
+
export * from './cleanAndValidate';
|
|
16
|
+
export * from './fieldType';
|
|
17
|
+
export * from './schemaWithName';
|
|
18
|
+
export * from './cloneSchema';
|
package/dist/index.js
CHANGED
|
@@ -861,7 +861,8 @@ function getArrayNode(schema2, value) {
|
|
|
861
861
|
var clean = async (info) => {
|
|
862
862
|
convertTypedSchema(info);
|
|
863
863
|
const { schema: schema2, args = [], value } = info;
|
|
864
|
-
const
|
|
864
|
+
const schemaValue = schema2;
|
|
865
|
+
const currSchema = typeof schemaValue === "object" && schemaValue !== null && "type" in schemaValue ? schemaValue : { type: schemaValue };
|
|
865
866
|
const objectSchema = getObjectNode(currSchema, value);
|
|
866
867
|
if (objectSchema) {
|
|
867
868
|
const newDoc = await cleanObjectFields({
|