@aeriajs/validation 0.0.24 → 0.0.26
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/dist/validate.js +9 -0
- package/dist/validate.mjs +9 -0
- package/package.json +3 -3
package/dist/validate.js
CHANGED
|
@@ -62,6 +62,15 @@ const validateProperty = (propName, what, property, options = {}) => {
|
|
|
62
62
|
if ('properties' in property) {
|
|
63
63
|
return (0, exports.validate)(what, property, options);
|
|
64
64
|
}
|
|
65
|
+
if ('const' in property) {
|
|
66
|
+
if (what !== property.const) {
|
|
67
|
+
return (0, common_1.left)(makePropertyError('unmatching', {
|
|
68
|
+
expected: property.const,
|
|
69
|
+
got: what,
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
return (0, common_1.right)(what);
|
|
73
|
+
}
|
|
65
74
|
const expectedType = getPropertyType(property);
|
|
66
75
|
const actualType = getValueType(what);
|
|
67
76
|
if ('enum' in property && property.enum.length === 0) {
|
package/dist/validate.mjs
CHANGED
|
@@ -66,6 +66,15 @@ export var validateProperty = function(propName, what, property) {
|
|
|
66
66
|
if ("properties" in property) {
|
|
67
67
|
return validate(what, property, options);
|
|
68
68
|
}
|
|
69
|
+
if ("const" in property) {
|
|
70
|
+
if (what !== property.const) {
|
|
71
|
+
return left(makePropertyError("unmatching", {
|
|
72
|
+
expected: property.const,
|
|
73
|
+
got: what
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
return right(what);
|
|
77
|
+
}
|
|
69
78
|
var expectedType = getPropertyType(property);
|
|
70
79
|
var actualType = getValueType(what);
|
|
71
80
|
if ("enum" in property && property.enum.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/validation",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
4
|
"description": "## Installation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@aeriajs/common": "^0.0.
|
|
26
|
-
"@aeriajs/types": "^0.0.
|
|
25
|
+
"@aeriajs/common": "^0.0.23",
|
|
26
|
+
"@aeriajs/types": "^0.0.20"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"test": "env TS_NODE_COMPILER_OPTIONS=\"$(cat ../compilerOptions.json)\" mocha -r ts-node/register tests/*.spec.ts",
|