@orion-js/schema 3.5.0 → 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 +11 -10
- package/lib/fieldTypes/index.js +3 -1
- package/lib/getValidationErrors/index.test.js +9 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -3
- 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
|
+
});
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
array: import("
|
|
3
|
-
plainObject: import("
|
|
4
|
-
string: import("
|
|
5
|
-
date: import("
|
|
6
|
-
integer: import("
|
|
7
|
-
number: import("
|
|
8
|
-
ID: import("
|
|
9
|
-
boolean: import("
|
|
10
|
-
email: import("
|
|
11
|
-
blackbox: import("
|
|
2
|
+
array: import("..").FieldType;
|
|
3
|
+
plainObject: import("..").FieldType;
|
|
4
|
+
string: import("..").FieldType;
|
|
5
|
+
date: import("..").FieldType;
|
|
6
|
+
integer: import("..").FieldType;
|
|
7
|
+
number: import("..").FieldType;
|
|
8
|
+
ID: import("..").FieldType;
|
|
9
|
+
boolean: import("..").FieldType;
|
|
10
|
+
email: import("..").FieldType;
|
|
11
|
+
blackbox: import("..").FieldType;
|
|
12
|
+
any: import("..").FieldType;
|
|
12
13
|
};
|
|
13
14
|
export default _default;
|
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/index.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ import ValidationError from './ValidationError';
|
|
|
3
3
|
import getValidationErrors from './getValidationErrors';
|
|
4
4
|
import isValid from './isValid';
|
|
5
5
|
import getFieldType from './getValidationErrors/getError/getFieldType';
|
|
6
|
-
import fieldType from './fieldType';
|
|
7
6
|
import clean from './clean';
|
|
8
7
|
import cleanKey from './cleanKey';
|
|
9
8
|
import validateKey from './validateKey';
|
|
10
9
|
import dotGetSchema from './dotGetSchema';
|
|
11
10
|
import createEnum from './fieldTypes/enum';
|
|
12
|
-
export { validate, ValidationError, getValidationErrors, isValid, getFieldType,
|
|
11
|
+
export { validate, ValidationError, getValidationErrors, isValid, getFieldType, clean, cleanKey, dotGetSchema, validateKey, createEnum };
|
|
13
12
|
export * from './types';
|
|
13
|
+
export * from './fieldType';
|
package/lib/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.createEnum = exports.validateKey = exports.dotGetSchema = exports.cleanKey = exports.clean = exports.
|
|
20
|
+
exports.createEnum = exports.validateKey = exports.dotGetSchema = exports.cleanKey = exports.clean = exports.getFieldType = exports.isValid = exports.getValidationErrors = exports.ValidationError = exports.validate = void 0;
|
|
21
21
|
const validate_1 = __importDefault(require("./validate"));
|
|
22
22
|
exports.validate = validate_1.default;
|
|
23
23
|
const ValidationError_1 = __importDefault(require("./ValidationError"));
|
|
@@ -28,8 +28,6 @@ const isValid_1 = __importDefault(require("./isValid"));
|
|
|
28
28
|
exports.isValid = isValid_1.default;
|
|
29
29
|
const getFieldType_1 = __importDefault(require("./getValidationErrors/getError/getFieldType"));
|
|
30
30
|
exports.getFieldType = getFieldType_1.default;
|
|
31
|
-
const fieldType_1 = __importDefault(require("./fieldType"));
|
|
32
|
-
exports.fieldType = fieldType_1.default;
|
|
33
31
|
const clean_1 = __importDefault(require("./clean"));
|
|
34
32
|
exports.clean = clean_1.default;
|
|
35
33
|
const cleanKey_1 = __importDefault(require("./cleanKey"));
|
|
@@ -41,3 +39,4 @@ exports.dotGetSchema = dotGetSchema_1.default;
|
|
|
41
39
|
const enum_1 = __importDefault(require("./fieldTypes/enum"));
|
|
42
40
|
exports.createEnum = enum_1.default;
|
|
43
41
|
__exportStar(require("./types"), exports);
|
|
42
|
+
__exportStar(require("./fieldType"), exports);
|
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.5
|
|
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
|
}
|