isvalid 4.0.21 → 4.0.23
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/lib/formalize.js +1 -1
- package/package.json +3 -3
- package/test/formalize.js +8 -0
package/lib/formalize.js
CHANGED
|
@@ -136,7 +136,7 @@ const formalizeAny = (schema, options = {}) => {
|
|
|
136
136
|
'len': [ 'string', 'number' ],
|
|
137
137
|
'match': [ 'regexp' ],
|
|
138
138
|
'trim': [ 'boolean' ],
|
|
139
|
-
'enum': [ 'array' ]
|
|
139
|
+
'enum': [ 'array', 'object' ]
|
|
140
140
|
});
|
|
141
141
|
if (isSameType('number', typeName(type))) merge(validators, {
|
|
142
142
|
'range': [ 'string', 'number', testFormalizedRange ],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isvalid",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.23",
|
|
4
4
|
"description": "Async JSON validation library for node.js.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@trenskow/caseit": "^1.3.11",
|
|
23
23
|
"body-parser": "^1.20.2",
|
|
24
|
-
"chai": "^5.0.
|
|
24
|
+
"chai": "^5.0.3",
|
|
25
25
|
"chai-as-promised": "^7.1.1",
|
|
26
26
|
"eslint": "^8.56.0",
|
|
27
27
|
"express": "^4.18.2",
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"url": "https://github.com/trenskow"
|
|
43
43
|
},
|
|
44
44
|
"overrides": {
|
|
45
|
-
"chai": "^5.0.
|
|
45
|
+
"chai": "^5.0.3"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/test/formalize.js
CHANGED
|
@@ -52,6 +52,14 @@ describe('schema', function() {
|
|
|
52
52
|
.to.have.property('errors')
|
|
53
53
|
.to.have.property('enum', 'Must be this or test.');
|
|
54
54
|
});
|
|
55
|
+
it('should come back with enum allowed if it is an object.', () => {
|
|
56
|
+
expect(formalize({ type: String, enum: { this: 'this is', test: 'a test' } }))
|
|
57
|
+
.to.have.property('enum')
|
|
58
|
+
.to.eql({
|
|
59
|
+
'this': 'this is',
|
|
60
|
+
'test': 'a test'
|
|
61
|
+
});
|
|
62
|
+
});
|
|
55
63
|
it('should throw an error if schema type cannot be determined.', () => {
|
|
56
64
|
expect(f({ type: '' })).to.throw(SchemaError);
|
|
57
65
|
});
|