@orion-js/schema 3.6.1 → 3.6.5
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/any.d.ts +2 -0
- package/lib/fieldTypes/any.js +10 -0
- package/lib/fieldTypes/any.test.d.ts +1 -0
- package/lib/fieldTypes/any.test.js +13 -0
- package/lib/fieldTypes/index.d.ts +1 -0
- package/lib/fieldTypes/index.js +3 -1
- package/lib/getValidationErrors/index.test.js +9 -0
- package/lib/types/schema.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fieldType_1 = __importDefault(require("../fieldType"));
|
|
7
|
+
exports.default = (0, fieldType_1.default)({
|
|
8
|
+
name: 'any',
|
|
9
|
+
validate(value) { }
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const any_1 = __importDefault(require("./any"));
|
|
7
|
+
test('return no error when the value is correct', async () => {
|
|
8
|
+
expect(any_1.default.validate({ name: null })).toBeFalsy();
|
|
9
|
+
expect(any_1.default.validate({ name: 'Nicolás' })).toBeFalsy();
|
|
10
|
+
expect(any_1.default.validate(1)).toBeFalsy();
|
|
11
|
+
expect(any_1.default.validate('string')).toBeFalsy();
|
|
12
|
+
expect(any_1.default.validate(['hello'])).toBeFalsy();
|
|
13
|
+
});
|
package/lib/fieldTypes/index.js
CHANGED
|
@@ -13,6 +13,7 @@ const ID_1 = __importDefault(require("./ID"));
|
|
|
13
13
|
const boolean_1 = __importDefault(require("./boolean"));
|
|
14
14
|
const email_1 = __importDefault(require("./email"));
|
|
15
15
|
const blackbox_1 = __importDefault(require("./blackbox"));
|
|
16
|
+
const any_1 = __importDefault(require("./any"));
|
|
16
17
|
exports.default = {
|
|
17
18
|
array: array_1.default,
|
|
18
19
|
plainObject: plainObject_1.default,
|
|
@@ -23,5 +24,6 @@ exports.default = {
|
|
|
23
24
|
ID: ID_1.default,
|
|
24
25
|
boolean: boolean_1.default,
|
|
25
26
|
email: email_1.default,
|
|
26
|
-
blackbox: blackbox_1.default
|
|
27
|
+
blackbox: blackbox_1.default,
|
|
28
|
+
any: any_1.default
|
|
27
29
|
};
|
|
@@ -301,6 +301,15 @@ test('allow custom validation to pass an error object', async () => {
|
|
|
301
301
|
'person.lastName': 'tooShort'
|
|
302
302
|
});
|
|
303
303
|
});
|
|
304
|
+
test('allow to set type any', async () => {
|
|
305
|
+
const schema = {
|
|
306
|
+
person: {
|
|
307
|
+
type: 'any'
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
const errors = await (0, index_1.default)(schema, { person: { lastName: 'López' } });
|
|
311
|
+
expect(errors).toEqual(null);
|
|
312
|
+
});
|
|
304
313
|
test('allow custom validation to pass an complex error object', async () => {
|
|
305
314
|
const schema = {
|
|
306
315
|
person: {
|
package/lib/types/schema.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type Constructor<T> = new (...args: any[]) => T;
|
|
|
3
3
|
export type Blackbox = {
|
|
4
4
|
[name: string]: any;
|
|
5
5
|
};
|
|
6
|
-
export type FieldTypesList = 'string' | 'date' | 'integer' | 'number' | 'ID' | 'boolean' | 'email' | 'blackbox';
|
|
6
|
+
export type FieldTypesList = 'string' | 'date' | 'integer' | 'number' | 'ID' | 'boolean' | 'email' | 'blackbox' | 'any';
|
|
7
7
|
export type TypedModelOnSchema = Function;
|
|
8
8
|
export type ConstructorsTypesList = Constructor<String> | Constructor<Number> | Constructor<Boolean> | Constructor<Date>;
|
|
9
9
|
export type SchemaRecursiveNodeTypeExtras = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/schema",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.5",
|
|
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": "1aa2e98c9e6cd7e82b19c335910d751ec2d2b03e"
|
|
35
35
|
}
|