@orion-js/schema 3.3.12 → 3.3.13
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/fieldTypes/enum.js
CHANGED
|
@@ -24,6 +24,8 @@ function default_1(type) {
|
|
|
24
24
|
return 'number';
|
|
25
25
|
if (type === Boolean)
|
|
26
26
|
return 'boolean';
|
|
27
|
+
if (type === 'enum')
|
|
28
|
+
return 'string';
|
|
27
29
|
if (!(0, isString_1.default)(type)) {
|
|
28
30
|
throw new Error('Field type is invalid. Pass a string or a custom field type. Got ' + type);
|
|
29
31
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const getFieldValidator_1 = __importDefault(require("./getFieldValidator"));
|
|
7
7
|
const fieldType_1 = __importDefault(require("../../fieldType"));
|
|
8
8
|
const getFieldType_1 = __importDefault(require("./getFieldType"));
|
|
9
|
+
const __1 = require("../..");
|
|
9
10
|
test('returns object validator when an object is passed', async () => {
|
|
10
11
|
const validator = (0, getFieldValidator_1.default)({ name: { type: String } });
|
|
11
12
|
expect(validator).toBe('plainObject');
|
|
@@ -59,3 +60,13 @@ test('returns unkown field validator when an unkown type string is passed', asyn
|
|
|
59
60
|
expect(error.message).toMatch(/Field type does not exist/);
|
|
60
61
|
}
|
|
61
62
|
});
|
|
63
|
+
test('passes when field type is custom (for client side)', async () => {
|
|
64
|
+
const schema = {
|
|
65
|
+
name: {
|
|
66
|
+
type: 'enum'
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
await (0, __1.clean)(schema, { name: 'test' });
|
|
70
|
+
await (0, __1.validate)(schema, { name: 'test' });
|
|
71
|
+
(0, getFieldValidator_1.default)('enum');
|
|
72
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/schema",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.13",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "8b63161dd4c14fa182571eb46a7fb87a67895a07"
|
|
35
35
|
}
|