@orion-js/schema 3.6.1 → 3.7.1

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.
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../fieldType").FieldType;
2
+ export default _default;
@@ -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
+ });
@@ -9,5 +9,6 @@ declare const _default: {
9
9
  boolean: import("..").FieldType;
10
10
  email: import("..").FieldType;
11
11
  blackbox: import("..").FieldType;
12
+ any: import("..").FieldType;
12
13
  };
13
14
  export default _default;
@@ -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: {
@@ -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.1",
3
+ "version": "3.7.1",
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": "ce643e657e199d1893c8c0f1d067d96e542f1796"
34
+ "gitHead": "b34633e2a999e3db3cde99582dacea704f23429c"
35
35
  }