@bedrockio/yada 1.4.0 → 1.4.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.
- package/CHANGELOG.md +4 -0
- package/dist/cjs/Schema.js +2 -2
- package/dist/cjs/array.js +2 -2
- package/dist/cjs/object.js +5 -5
- package/package.json +2 -2
- package/src/Schema.js +1 -1
- package/src/array.js +1 -1
- package/src/object.js +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/Schema.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.isSchema = isSchema;
|
|
8
|
-
var
|
|
8
|
+
var _lodash = require("lodash");
|
|
9
9
|
var _errors = require("./errors");
|
|
10
10
|
const INITIAL_TYPES = ['default', 'required', 'type', 'transform', 'empty'];
|
|
11
11
|
const REQUIRED_TYPES = ['default', 'required', 'missing'];
|
|
@@ -307,7 +307,7 @@ class Schema {
|
|
|
307
307
|
// Must not pass cast option down when allowing
|
|
308
308
|
// other schema types as they may be allowed, for
|
|
309
309
|
// example allowing a string or array of strings.
|
|
310
|
-
options = (0,
|
|
310
|
+
options = (0, _lodash.omit)(options, 'cast');
|
|
311
311
|
return await el.validate(val, options);
|
|
312
312
|
} catch (err) {
|
|
313
313
|
const [first] = err.details;
|
package/dist/cjs/array.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = _default;
|
|
7
|
-
var
|
|
7
|
+
var _lodash = require("lodash");
|
|
8
8
|
var _Schema = _interopRequireDefault(require("./Schema"));
|
|
9
9
|
var _TypeSchema = _interopRequireDefault(require("./TypeSchema"));
|
|
10
10
|
var _errors = require("./errors");
|
|
@@ -42,7 +42,7 @@ class ArraySchema extends _TypeSchema.default {
|
|
|
42
42
|
try {
|
|
43
43
|
// Allow enum message to take
|
|
44
44
|
// precedence over generic array message.
|
|
45
|
-
options = (0,
|
|
45
|
+
options = (0, _lodash.omit)(options, 'message');
|
|
46
46
|
result.push(await schema.validate(el, options));
|
|
47
47
|
} catch (error) {
|
|
48
48
|
errors.push(new _errors.ElementError(message, i, error.details));
|
package/dist/cjs/object.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = _default;
|
|
7
|
-
var
|
|
7
|
+
var _lodash = require("lodash");
|
|
8
8
|
var _TypeSchema = _interopRequireDefault(require("./TypeSchema"));
|
|
9
9
|
var _errors = require("./errors");
|
|
10
10
|
var _Schema = _interopRequireWildcard(require("./Schema"));
|
|
@@ -84,7 +84,7 @@ class ObjectSchema extends _TypeSchema.default {
|
|
|
84
84
|
try {
|
|
85
85
|
// Do not pass down message into validators
|
|
86
86
|
// to allow custom messages to take precedence.
|
|
87
|
-
options = (0,
|
|
87
|
+
options = (0, _lodash.omit)(options, 'message');
|
|
88
88
|
const result = await schema.validate(val, {
|
|
89
89
|
...options,
|
|
90
90
|
// The root object may have been transformed here
|
|
@@ -170,7 +170,7 @@ class ObjectSchema extends _TypeSchema.default {
|
|
|
170
170
|
names = names[0];
|
|
171
171
|
}
|
|
172
172
|
return new ObjectSchema({
|
|
173
|
-
fields: (0,
|
|
173
|
+
fields: (0, _lodash.pick)(this.meta.fields, names)
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
176
|
|
|
@@ -184,7 +184,7 @@ class ObjectSchema extends _TypeSchema.default {
|
|
|
184
184
|
names = names[0];
|
|
185
185
|
}
|
|
186
186
|
return new ObjectSchema({
|
|
187
|
-
fields: (0,
|
|
187
|
+
fields: (0, _lodash.omit)(this.meta.fields, names)
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
|
|
@@ -205,7 +205,7 @@ class ObjectSchema extends _TypeSchema.default {
|
|
|
205
205
|
}
|
|
206
206
|
const update = {};
|
|
207
207
|
for (let field of fields) {
|
|
208
|
-
(0,
|
|
208
|
+
(0, _lodash.set)(update, field, this.get(field).required());
|
|
209
209
|
}
|
|
210
210
|
return this.append(update);
|
|
211
211
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bedrockio/yada",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Validation library inspired by Joi.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "Andrew Plummer <plummer.andrew@gmail.com>",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"lodash
|
|
20
|
+
"lodash": "^4.17.21",
|
|
21
21
|
"validator": "^13.9.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
package/src/Schema.js
CHANGED
package/src/array.js
CHANGED
package/src/object.js
CHANGED