You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validates a document against a collection schema. It returns a Promise that is resolved with `undefined` if no validation errors occur, or rejected with an array of errors if validation fails.
42
77
78
+
If `isUpdate` is set to `true`, the method does not throw a validation error if a required field is missing from the candidate document, because it is inferred that a partial update, as opposed to a full document, is being evaluated.
79
+
43
80
```js
44
81
constmySchema= {
45
82
title: {
@@ -51,7 +88,7 @@ const mySchema = {
51
88
}
52
89
53
90
// Rejected Promise:
54
-
// > [{"field": "title", "code": "ERROR_MIN_LENGTH", "message": "is too short"}]
Same as `validateDocument` but expects an array of documents (as the `documents` property) and performs validation on each one of them, aborting the process once one of the documents fails validation.
77
114
115
+
### `validateSchemaField(name, schema)`
116
+
117
+
Validates a field schema, evaluating whether `name` is a valid field name and whether `schema` is a valid schema object.
Validates a candidate value against a field schema. It returns a Promise that is resolved with `undefined` if no validation errors occur, or rejected with an error object if validation fails.
@@ -90,7 +207,7 @@ const mySchema = {
90
207
}
91
208
92
209
// Rejected Promise:
93
-
// > {"field": "title", "code": "ERROR_MIN_LENGTH", "message": "is too short"}
When a `validationCallback` property is found in `schema`, it is used as a callback function that allows the user to supply additional validation logic that will be executed after the normal validation runs. This function should return a Promise that rejects when validation fails, passing down an error object with an optional `code` property that indicates the error code.
227
+
109
228
## License
110
229
111
230
DADI is a data centric development and delivery stack, built specifically in support of the principles of API first and COPE.
0 commit comments