@bedrockio/yada 1.0.14 → 1.0.15

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.
@@ -21,6 +21,9 @@ class Schema {
21
21
 
22
22
  // Public
23
23
 
24
+ /**
25
+ * @returns {this}
26
+ */
24
27
  required() {
25
28
  return this.clone({
26
29
  required: true
@@ -30,6 +33,11 @@ class Schema {
30
33
  }
31
34
  });
32
35
  }
36
+
37
+ /**
38
+ * Sets the schema default. [Link](https://github.com/bedrockio/yada#default)
39
+ * @returns {this}
40
+ */
33
41
  default(value) {
34
42
  return this.clone({
35
43
  default: value
@@ -41,7 +49,9 @@ class Schema {
41
49
  }
42
50
 
43
51
  /**
52
+ * Validate by a custom function. [Link](https://github.com/bedrockio/yada#custom)
44
53
  * @param {CustomSignature} args
54
+ * @returns {this}
45
55
  */
46
56
  custom(...args) {
47
57
  let type, fn;
@@ -61,22 +71,46 @@ class Schema {
61
71
  return await fn(val, options);
62
72
  });
63
73
  }
74
+
75
+ /**
76
+ * Conditionally exclude fields inside an object schema.
77
+ * [Link](https://github.com/bedrockio/yada#strip)
78
+ * @returns {this}
79
+ */
64
80
  strip(strip) {
65
81
  return this.clone({
66
82
  strip
67
83
  });
68
84
  }
85
+
86
+ /**
87
+ * Accept values or schemas. [Link](https://github.com/bedrockio/yada#allow)
88
+ * @returns {this}
89
+ */
69
90
  allow(...set) {
70
91
  return this.assertEnum(set, true);
71
92
  }
93
+
94
+ /**
95
+ * Reject values or schemas. [Link](https://github.com/bedrockio/yada#reject)
96
+ * @returns {this}
97
+ */
72
98
  reject(...set) {
73
99
  return this.assertEnum(set, false);
74
100
  }
101
+
102
+ /**
103
+ * @returns {this}
104
+ */
75
105
  message(message) {
76
106
  return this.clone({
77
107
  message
78
108
  });
79
109
  }
110
+
111
+ /**
112
+ * @returns {this}
113
+ */
80
114
  tag(tags) {
81
115
  return this.clone({
82
116
  tags: {
@@ -85,11 +119,19 @@ class Schema {
85
119
  }
86
120
  });
87
121
  }
122
+
123
+ /**
124
+ * @returns {this}
125
+ */
88
126
  description(description) {
89
127
  return this.tag({
90
128
  description
91
129
  });
92
130
  }
131
+
132
+ /**
133
+ * @returns {this}
134
+ */
93
135
  options(options) {
94
136
  return this.clone({
95
137
  ...options
@@ -146,7 +188,8 @@ class Schema {
146
188
  }
147
189
 
148
190
  /**
149
- * @returns {Schema}
191
+ * Appends another schema. [Link](https://github.com/bedrockio/yada#append)
192
+ * @returns {this}
150
193
  */
151
194
  append(schema) {
152
195
  const merged = this.clone(schema.meta);
@@ -178,6 +221,9 @@ class Schema {
178
221
 
179
222
  // Private
180
223
 
224
+ /**
225
+ * @returns {this}
226
+ */
181
227
  assertEnum(set, allow) {
182
228
  if (set.length === 1 && Array.isArray(set[0])) {
183
229
  set = set[0];
@@ -211,6 +257,10 @@ class Schema {
211
257
  }
212
258
  });
213
259
  }
260
+
261
+ /**
262
+ * @returns {this}
263
+ */
214
264
  assert(type, fn) {
215
265
  this.pushAssertion({
216
266
  halt: INITIAL_TYPES.includes(type),
@@ -226,6 +276,10 @@ class Schema {
226
276
  return this.getSortIndex(a.type) - this.getSortIndex(b.type);
227
277
  });
228
278
  }
279
+
280
+ /**
281
+ * @returns {this}
282
+ */
229
283
  transform(fn) {
230
284
  this.assert('transform', (val, options) => {
231
285
  if (val !== undefined) {
package/dist/cjs/array.js CHANGED
@@ -3,23 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = _default;
7
7
  var _Schema = _interopRequireDefault(require("./Schema"));
8
8
  var _errors = require("./errors");
9
- var _utils = require("./utils");
10
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
10
  class ArraySchema extends _Schema.default {
12
- constructor(...args) {
13
- let schemas, meta;
14
- if (Array.isArray(args[0])) {
15
- schemas = args[0];
16
- meta = args[1];
17
- } else {
18
- schemas = args;
19
- }
11
+ constructor(schemas) {
20
12
  super({
21
13
  message: 'Array failed validation.',
22
- ...meta,
23
14
  schemas
24
15
  });
25
16
  this.setup();
@@ -143,10 +134,16 @@ class ArraySchema extends _Schema.default {
143
134
  }
144
135
 
145
136
  /**
146
- * @type {{
147
- * (...schemas: Schema[]) : ArraySchema;
148
- * (schemas: Schema[]) : ArraySchema;
149
- * }}
137
+ * Creates an [array schema](https://github.com/bedrockio/yada#array).
138
+ *
139
+ * @param {...Schema} [schemas] Optional schemas to validate
140
+ * the different types of elements allowed in the array. If
141
+ * no arguments are passed elements may be of any type. Also
142
+ * accepts a single array argument.
150
143
  */
151
- var _default = (0, _utils.wrapSchema)(ArraySchema);
152
- exports.default = _default;
144
+ function _default(...schemas) {
145
+ if (Array.isArray(schemas[0])) {
146
+ schemas = schemas[0];
147
+ }
148
+ return new ArraySchema(schemas);
149
+ }
@@ -3,10 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = _default;
7
7
  var _TypeSchema = _interopRequireDefault(require("./TypeSchema"));
8
8
  var _errors = require("./errors");
9
- var _utils = require("./utils");
10
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
10
  class BooleanSchema extends _TypeSchema.default {
12
11
  constructor() {
@@ -29,7 +28,8 @@ class BooleanSchema extends _TypeSchema.default {
29
28
  }
30
29
 
31
30
  /**
32
- * @type {function(): BooleanSchema}
31
+ * Creates a [boolean schema](https://github.com/bedrockio/yada#boolean).
33
32
  */
34
- var _default = (0, _utils.wrapSchema)(BooleanSchema);
35
- exports.default = _default;
33
+ function _default() {
34
+ return new BooleanSchema();
35
+ }
package/dist/cjs/date.js CHANGED
@@ -3,9 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = _default;
7
7
  var _validator = _interopRequireDefault(require("validator"));
8
- var _utils = require("./utils");
9
8
  var _errors = require("./errors");
10
9
  var _Schema = _interopRequireDefault(require("./Schema"));
11
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -154,7 +153,8 @@ class DateSchema extends _Schema.default {
154
153
  }
155
154
 
156
155
  /**
157
- * @type {() => DateSchema}
156
+ * Creates a [date schema](https://github.com/bedrockio/yada#date).
158
157
  */
159
- var _default = (0, _utils.wrapSchema)(DateSchema);
160
- exports.default = _default;
158
+ function _default() {
159
+ return new DateSchema();
160
+ }
package/dist/cjs/index.js CHANGED
@@ -85,17 +85,29 @@ var _utils = require("./utils");
85
85
  var _localization = require("./localization");
86
86
  var _errors = require("./errors");
87
87
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
88
+ /**
89
+ * Accepts anything.
90
+ */
88
91
  function any() {
89
92
  return new _Schema.default();
90
93
  }
94
+
95
+ /**
96
+ * Accept values or schemas. [Link](https://github.com/bedrockio/yada#allow)
97
+ */
91
98
  function allow(...args) {
92
99
  return new _Schema.default().allow(...args);
93
100
  }
101
+
102
+ /**
103
+ * Reject values or schemas. [Link](https://github.com/bedrockio/yada#reject)
104
+ */
94
105
  function reject(...args) {
95
106
  return new _Schema.default().reject(...args);
96
107
  }
97
108
 
98
109
  /**
110
+ * Validate by a custom function. [Link](https://github.com/bedrockio/yada#custom)
99
111
  * @param {import("./Schema").CustomSignature} args
100
112
  */
101
113
  function custom(...args) {
@@ -3,10 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = _default;
7
7
  var _TypeSchema = _interopRequireDefault(require("./TypeSchema"));
8
8
  var _errors = require("./errors");
9
- var _utils = require("./utils");
10
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
10
  class NumberSchema extends _TypeSchema.default {
12
11
  constructor() {
@@ -99,7 +98,8 @@ class NumberSchema extends _TypeSchema.default {
99
98
  }
100
99
 
101
100
  /**
102
- * @type {() => NumberSchema}
101
+ * Creates a [number schema](https://github.com/bedrockio/yada#number).
103
102
  */
104
- var _default = (0, _utils.wrapSchema)(NumberSchema);
105
- exports.default = _default;
103
+ function _default() {
104
+ return new NumberSchema();
105
+ }
@@ -3,13 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = _default;
7
7
  var _TypeSchema = _interopRequireDefault(require("./TypeSchema"));
8
8
  var _errors = require("./errors");
9
- var _utils = require("./utils");
10
- var _Schema = require("./Schema");
9
+ var _Schema = _interopRequireDefault(require("./Schema"));
11
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
11
  const BASE_ASSERTIONS = ['type', 'transform', 'field'];
12
+
13
+ /**
14
+ * @typedef {{ [key: string]: Schema } | {}} SchemaMap
15
+ */
16
+
13
17
  class ObjectSchema extends _TypeSchema.default {
14
18
  constructor(fields) {
15
19
  super(Object, {
@@ -91,14 +95,21 @@ class ObjectSchema extends _TypeSchema.default {
91
95
  }
92
96
 
93
97
  /**
94
- * @param {object|ObjectSchema} arg
95
- * @returns Schema
98
+ * @private
99
+ */
100
+ getFields() {
101
+ return this.meta.fields || {};
102
+ }
103
+
104
+ /**
105
+ * @param {SchemaMap|Schema} arg Object or schema to append.
96
106
  */
107
+ // @ts-ignore
97
108
  append(arg) {
98
109
  let schema;
99
110
  if (arg instanceof ObjectSchema) {
100
111
  schema = arg;
101
- } else if ((0, _Schema.isSchema)(arg)) {
112
+ } else if (arg instanceof _Schema.default) {
102
113
  // If the schema is of a different type then
103
114
  // simply append it and don't merge fields.
104
115
  return super.append(arg);
@@ -121,9 +132,6 @@ class ObjectSchema extends _TypeSchema.default {
121
132
  }
122
133
  return merged;
123
134
  }
124
- getFields() {
125
- return this.meta.fields || {};
126
- }
127
135
  toOpenApi(extra) {
128
136
  const properties = {};
129
137
  for (let [key, schema] of Object.entries(this.getFields())) {
@@ -139,7 +147,12 @@ class ObjectSchema extends _TypeSchema.default {
139
147
  }
140
148
 
141
149
  /**
142
- * @type {(arg: object) => ObjectSchema}
150
+ * Creates an [object schema](https://github.com/bedrockio/yada#object).
151
+ *
152
+ * @param {SchemaMap} [map] An map of keys to schemas.
153
+ * If not passed any object shape will be allowed. If an
154
+ * empty object is passed then no keys will be allowed.
143
155
  */
144
- var _default = (0, _utils.wrapSchema)(ObjectSchema);
145
- exports.default = _default;
156
+ function _default(map) {
157
+ return new ObjectSchema(map);
158
+ }
@@ -3,11 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = _default;
7
7
  var _validator = _interopRequireDefault(require("validator"));
8
8
  var _TypeSchema = _interopRequireDefault(require("./TypeSchema"));
9
9
  var _errors = require("./errors");
10
- var _utils = require("./utils");
11
10
  var _password = require("./password");
12
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
12
  const SLUG_REG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
@@ -150,7 +149,7 @@ class StringSchema extends _TypeSchema.default {
150
149
  }
151
150
 
152
151
  /**
153
- * @param {Object} [options]
152
+ * @param {object} [options]
154
153
  * @param {boolean} [options.urlSafe]
155
154
  */
156
155
  base64(options) {
@@ -223,7 +222,7 @@ class StringSchema extends _TypeSchema.default {
223
222
  }
224
223
 
225
224
  /**
226
- * @param {Object} [options]
225
+ * @param {object} [options]
227
226
  * @param {number} [options.minLength]
228
227
  * @param {number} [options.minNumbers]
229
228
  * @param {number} [options.minSymbols]
@@ -261,7 +260,7 @@ class StringSchema extends _TypeSchema.default {
261
260
  }
262
261
 
263
262
  /**
264
- * @param {Object} [options]
263
+ * @param {object} [options]
265
264
  * @param {boolean} [options.require_protocol]
266
265
  * @param {boolean} [options.require_valid_protocol]
267
266
  * @param {boolean} [options.require_host]
@@ -281,7 +280,7 @@ class StringSchema extends _TypeSchema.default {
281
280
  }
282
281
 
283
282
  /**
284
- * @param {Object} [options]
283
+ * @param {object} [options]
285
284
  * @param {boolean} [options.require_tld=true]
286
285
  * @param {boolean} [options.allow_underscores=false]
287
286
  * @param {boolean} [options.allow_trailing_dot=false]
@@ -353,7 +352,8 @@ class StringSchema extends _TypeSchema.default {
353
352
  }
354
353
 
355
354
  /**
356
- * @type {() => StringSchema}
355
+ * Creates a [string schema](https://github.com/bedrockio/yada#string).
357
356
  */
358
- var _default = (0, _utils.wrapSchema)(StringSchema);
359
- exports.default = _default;
357
+ function _default() {
358
+ return new StringSchema();
359
+ }
package/dist/cjs/utils.js CHANGED
@@ -15,11 +15,5 @@ Object.defineProperty(exports, "isSchemaError", {
15
15
  return _errors.isSchemaError;
16
16
  }
17
17
  });
18
- exports.wrapSchema = wrapSchema;
19
18
  var _Schema = require("./Schema");
20
- var _errors = require("./errors");
21
- function wrapSchema(Class) {
22
- return (...args) => {
23
- return new Class(...args);
24
- };
25
- }
19
+ var _errors = require("./errors");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/yada",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "Validation library inspired by Joi.",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -20,9 +20,9 @@
20
20
  "validator": "^13.9.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@babel/cli": "^7.19.3",
24
- "@babel/core": "^7.19.6",
25
- "@babel/preset-env": "^7.19.4",
23
+ "@babel/cli": "^7.20.7",
24
+ "@babel/core": "^7.20.12",
25
+ "@babel/preset-env": "^7.20.2",
26
26
  "@bedrockio/prettier-config": "^1.0.2",
27
27
  "babel-plugin-add-module-exports": "^1.0.4",
28
28
  "eslint": "^8.26.0",
@@ -31,12 +31,6 @@
31
31
  "prettier": "^2.7.1",
32
32
  "typescript": "^4.9.5"
33
33
  },
34
- "exports": {
35
- ".": {
36
- "import": "./src/index.js",
37
- "require": "./dist/cjs/index.js"
38
- }
39
- },
40
34
  "prettier": "@bedrockio/prettier-config",
41
35
  "volta": {
42
36
  "node": "18.13.0",
package/src/Schema.js CHANGED
@@ -21,6 +21,9 @@ export default class Schema {
21
21
 
22
22
  // Public
23
23
 
24
+ /**
25
+ * @returns {this}
26
+ */
24
27
  required() {
25
28
  return this.clone({ required: true }).assert('required', (val) => {
26
29
  if (val === undefined) {
@@ -29,6 +32,10 @@ export default class Schema {
29
32
  });
30
33
  }
31
34
 
35
+ /**
36
+ * Sets the schema default. [Link](https://github.com/bedrockio/yada#default)
37
+ * @returns {this}
38
+ */
32
39
  default(value) {
33
40
  return this.clone({ default: value }).assert('default', (val) => {
34
41
  if (val === undefined) {
@@ -38,7 +45,9 @@ export default class Schema {
38
45
  }
39
46
 
40
47
  /**
48
+ * Validate by a custom function. [Link](https://github.com/bedrockio/yada#custom)
41
49
  * @param {CustomSignature} args
50
+ * @returns {this}
42
51
  */
43
52
  custom(...args) {
44
53
  let type, fn;
@@ -59,22 +68,41 @@ export default class Schema {
59
68
  });
60
69
  }
61
70
 
71
+ /**
72
+ * Conditionally exclude fields inside an object schema.
73
+ * [Link](https://github.com/bedrockio/yada#strip)
74
+ * @returns {this}
75
+ */
62
76
  strip(strip) {
63
77
  return this.clone({ strip });
64
78
  }
65
79
 
80
+ /**
81
+ * Accept values or schemas. [Link](https://github.com/bedrockio/yada#allow)
82
+ * @returns {this}
83
+ */
66
84
  allow(...set) {
67
85
  return this.assertEnum(set, true);
68
86
  }
69
87
 
88
+ /**
89
+ * Reject values or schemas. [Link](https://github.com/bedrockio/yada#reject)
90
+ * @returns {this}
91
+ */
70
92
  reject(...set) {
71
93
  return this.assertEnum(set, false);
72
94
  }
73
95
 
96
+ /**
97
+ * @returns {this}
98
+ */
74
99
  message(message) {
75
100
  return this.clone({ message });
76
101
  }
77
102
 
103
+ /**
104
+ * @returns {this}
105
+ */
78
106
  tag(tags) {
79
107
  return this.clone({
80
108
  tags: {
@@ -84,12 +112,18 @@ export default class Schema {
84
112
  });
85
113
  }
86
114
 
115
+ /**
116
+ * @returns {this}
117
+ */
87
118
  description(description) {
88
119
  return this.tag({
89
120
  description,
90
121
  });
91
122
  }
92
123
 
124
+ /**
125
+ * @returns {this}
126
+ */
93
127
  options(options) {
94
128
  return this.clone({ ...options });
95
129
  }
@@ -144,7 +178,8 @@ export default class Schema {
144
178
  }
145
179
 
146
180
  /**
147
- * @returns {Schema}
181
+ * Appends another schema. [Link](https://github.com/bedrockio/yada#append)
182
+ * @returns {this}
148
183
  */
149
184
  append(schema) {
150
185
  const merged = this.clone(schema.meta);
@@ -172,6 +207,9 @@ export default class Schema {
172
207
 
173
208
  // Private
174
209
 
210
+ /**
211
+ * @returns {this}
212
+ */
175
213
  assertEnum(set, allow) {
176
214
  if (set.length === 1 && Array.isArray(set[0])) {
177
215
  set = set[0];
@@ -204,6 +242,9 @@ export default class Schema {
204
242
  });
205
243
  }
206
244
 
245
+ /**
246
+ * @returns {this}
247
+ */
207
248
  assert(type, fn) {
208
249
  this.pushAssertion({
209
250
  halt: INITIAL_TYPES.includes(type),
@@ -221,6 +262,9 @@ export default class Schema {
221
262
  });
222
263
  }
223
264
 
265
+ /**
266
+ * @returns {this}
267
+ */
224
268
  transform(fn) {
225
269
  this.assert('transform', (val, options) => {
226
270
  if (val !== undefined) {
package/src/array.js CHANGED
@@ -1,19 +1,9 @@
1
1
  import Schema from './Schema';
2
2
  import { ArrayError, ElementError, LocalizedError } from './errors';
3
- import { wrapSchema } from './utils';
4
3
 
5
4
  class ArraySchema extends Schema {
6
- constructor(...args) {
7
- let schemas, meta;
8
-
9
- if (Array.isArray(args[0])) {
10
- schemas = args[0];
11
- meta = args[1];
12
- } else {
13
- schemas = args;
14
- }
15
-
16
- super({ message: 'Array failed validation.', ...meta, schemas });
5
+ constructor(schemas) {
6
+ super({ message: 'Array failed validation.', schemas });
17
7
  this.setup();
18
8
  }
19
9
 
@@ -144,9 +134,16 @@ class ArraySchema extends Schema {
144
134
  }
145
135
 
146
136
  /**
147
- * @type {{
148
- * (...schemas: Schema[]) : ArraySchema;
149
- * (schemas: Schema[]) : ArraySchema;
150
- * }}
137
+ * Creates an [array schema](https://github.com/bedrockio/yada#array).
138
+ *
139
+ * @param {...Schema} [schemas] Optional schemas to validate
140
+ * the different types of elements allowed in the array. If
141
+ * no arguments are passed elements may be of any type. Also
142
+ * accepts a single array argument.
151
143
  */
152
- export default wrapSchema(ArraySchema);
144
+ export default function (...schemas) {
145
+ if (Array.isArray(schemas[0])) {
146
+ schemas = schemas[0];
147
+ }
148
+ return new ArraySchema(schemas);
149
+ }
package/src/boolean.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import TypeSchema from './TypeSchema';
2
2
  import { LocalizedError } from './errors';
3
- import { wrapSchema } from './utils';
4
3
 
5
4
  class BooleanSchema extends TypeSchema {
6
5
  constructor() {
@@ -23,6 +22,8 @@ class BooleanSchema extends TypeSchema {
23
22
  }
24
23
 
25
24
  /**
26
- * @type {function(): BooleanSchema}
25
+ * Creates a [boolean schema](https://github.com/bedrockio/yada#boolean).
27
26
  */
28
- export default wrapSchema(BooleanSchema);
27
+ export default function () {
28
+ return new BooleanSchema();
29
+ }
package/src/date.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import validator from 'validator';
2
- import { wrapSchema } from './utils';
3
2
  import { LocalizedError } from './errors';
4
3
 
5
4
  import Schema from './Schema';
@@ -147,6 +146,8 @@ class DateSchema extends Schema {
147
146
  }
148
147
 
149
148
  /**
150
- * @type {() => DateSchema}
149
+ * Creates a [date schema](https://github.com/bedrockio/yada#date).
151
150
  */
152
- export default wrapSchema(DateSchema);
151
+ export default function () {
152
+ return new DateSchema();
153
+ }
package/src/index.js CHANGED
@@ -10,19 +10,29 @@ import { isSchema, isSchemaError } from './utils';
10
10
  import { useLocalizer, getLocalizedMessages } from './localization';
11
11
  import { LocalizedError } from './errors';
12
12
 
13
+ /**
14
+ * Accepts anything.
15
+ */
13
16
  function any() {
14
17
  return new Schema();
15
18
  }
16
19
 
20
+ /**
21
+ * Accept values or schemas. [Link](https://github.com/bedrockio/yada#allow)
22
+ */
17
23
  function allow(...args) {
18
24
  return new Schema().allow(...args);
19
25
  }
20
26
 
27
+ /**
28
+ * Reject values or schemas. [Link](https://github.com/bedrockio/yada#reject)
29
+ */
21
30
  function reject(...args) {
22
31
  return new Schema().reject(...args);
23
32
  }
24
33
 
25
34
  /**
35
+ * Validate by a custom function. [Link](https://github.com/bedrockio/yada#custom)
26
36
  * @param {import("./Schema").CustomSignature} args
27
37
  */
28
38
  function custom(...args) {
package/src/number.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import TypeSchema from './TypeSchema';
2
2
  import { LocalizedError } from './errors';
3
- import { wrapSchema } from './utils';
4
3
 
5
4
  class NumberSchema extends TypeSchema {
6
5
  constructor() {
@@ -88,6 +87,8 @@ class NumberSchema extends TypeSchema {
88
87
  }
89
88
 
90
89
  /**
91
- * @type {() => NumberSchema}
90
+ * Creates a [number schema](https://github.com/bedrockio/yada#number).
92
91
  */
93
- export default wrapSchema(NumberSchema);
92
+ export default function () {
93
+ return new NumberSchema();
94
+ }
package/src/object.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import TypeSchema from './TypeSchema';
2
2
  import { FieldError, LocalizedError } from './errors';
3
- import { wrapSchema } from './utils';
4
- import { isSchema } from './Schema';
3
+ import Schema from './Schema';
5
4
 
6
5
  const BASE_ASSERTIONS = ['type', 'transform', 'field'];
7
6
 
7
+ /**
8
+ * @typedef {{ [key: string]: Schema } | {}} SchemaMap
9
+ */
10
+
8
11
  class ObjectSchema extends TypeSchema {
9
12
  constructor(fields) {
10
13
  super(Object, { message: 'Object failed validation.', fields });
@@ -80,14 +83,21 @@ class ObjectSchema extends TypeSchema {
80
83
  }
81
84
 
82
85
  /**
83
- * @param {object|ObjectSchema} arg
84
- * @returns Schema
86
+ * @private
85
87
  */
88
+ getFields() {
89
+ return this.meta.fields || {};
90
+ }
91
+
92
+ /**
93
+ * @param {SchemaMap|Schema} arg Object or schema to append.
94
+ */
95
+ // @ts-ignore
86
96
  append(arg) {
87
97
  let schema;
88
98
  if (arg instanceof ObjectSchema) {
89
99
  schema = arg;
90
- } else if (isSchema(arg)) {
100
+ } else if (arg instanceof Schema) {
91
101
  // If the schema is of a different type then
92
102
  // simply append it and don't merge fields.
93
103
  return super.append(arg);
@@ -113,10 +123,6 @@ class ObjectSchema extends TypeSchema {
113
123
  return merged;
114
124
  }
115
125
 
116
- getFields() {
117
- return this.meta.fields || {};
118
- }
119
-
120
126
  toOpenApi(extra) {
121
127
  const properties = {};
122
128
  for (let [key, schema] of Object.entries(this.getFields())) {
@@ -132,6 +138,12 @@ class ObjectSchema extends TypeSchema {
132
138
  }
133
139
 
134
140
  /**
135
- * @type {(arg: object) => ObjectSchema}
141
+ * Creates an [object schema](https://github.com/bedrockio/yada#object).
142
+ *
143
+ * @param {SchemaMap} [map] An map of keys to schemas.
144
+ * If not passed any object shape will be allowed. If an
145
+ * empty object is passed then no keys will be allowed.
136
146
  */
137
- export default wrapSchema(ObjectSchema);
147
+ export default function (map) {
148
+ return new ObjectSchema(map);
149
+ }
package/src/string.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import validator from 'validator';
2
2
  import TypeSchema from './TypeSchema';
3
3
  import { LocalizedError } from './errors';
4
- import { wrapSchema } from './utils';
5
4
  import {
6
5
  PASSWORD_DEFAULTS,
7
6
  validateLength,
@@ -155,7 +154,7 @@ class StringSchema extends TypeSchema {
155
154
  }
156
155
 
157
156
  /**
158
- * @param {Object} [options]
157
+ * @param {object} [options]
159
158
  * @param {boolean} [options.urlSafe]
160
159
  */
161
160
  base64(options) {
@@ -235,7 +234,7 @@ class StringSchema extends TypeSchema {
235
234
  }
236
235
 
237
236
  /**
238
- * @param {Object} [options]
237
+ * @param {object} [options]
239
238
  * @param {number} [options.minLength]
240
239
  * @param {number} [options.minNumbers]
241
240
  * @param {number} [options.minSymbols]
@@ -270,7 +269,7 @@ class StringSchema extends TypeSchema {
270
269
  }
271
270
 
272
271
  /**
273
- * @param {Object} [options]
272
+ * @param {object} [options]
274
273
  * @param {boolean} [options.require_protocol]
275
274
  * @param {boolean} [options.require_valid_protocol]
276
275
  * @param {boolean} [options.require_host]
@@ -290,7 +289,7 @@ class StringSchema extends TypeSchema {
290
289
  }
291
290
 
292
291
  /**
293
- * @param {Object} [options]
292
+ * @param {object} [options]
294
293
  * @param {boolean} [options.require_tld=true]
295
294
  * @param {boolean} [options.allow_underscores=false]
296
295
  * @param {boolean} [options.allow_trailing_dot=false]
@@ -364,6 +363,8 @@ class StringSchema extends TypeSchema {
364
363
  }
365
364
 
366
365
  /**
367
- * @type {() => StringSchema}
366
+ * Creates a [string schema](https://github.com/bedrockio/yada#string).
368
367
  */
369
- export default wrapSchema(StringSchema);
368
+ export default function () {
369
+ return new StringSchema();
370
+ }
package/src/utils.js CHANGED
@@ -1,8 +1,2 @@
1
- export function wrapSchema(Class) {
2
- return (...args) => {
3
- return new Class(...args);
4
- };
5
- }
6
-
7
1
  export { isSchema } from './Schema';
8
2
  export { isSchemaError } from './errors';
package/types/Schema.d.ts CHANGED
@@ -6,33 +6,77 @@ export default class Schema {
6
6
  constructor(meta?: {});
7
7
  assertions: any[];
8
8
  meta: {};
9
- required(): Schema;
10
- default(value: any): Schema;
11
9
  /**
10
+ * @returns {this}
11
+ */
12
+ required(): this;
13
+ /**
14
+ * Sets the schema default. [Link](https://github.com/bedrockio/yada#default)
15
+ * @returns {this}
16
+ */
17
+ default(value: any): this;
18
+ /**
19
+ * Validate by a custom function. [Link](https://github.com/bedrockio/yada#custom)
12
20
  * @param {CustomSignature} args
21
+ * @returns {this}
22
+ */
23
+ custom(...args: CustomSignature): this;
24
+ /**
25
+ * Conditionally exclude fields inside an object schema.
26
+ * [Link](https://github.com/bedrockio/yada#strip)
27
+ * @returns {this}
28
+ */
29
+ strip(strip: any): this;
30
+ /**
31
+ * Accept values or schemas. [Link](https://github.com/bedrockio/yada#allow)
32
+ * @returns {this}
33
+ */
34
+ allow(...set: any[]): this;
35
+ /**
36
+ * Reject values or schemas. [Link](https://github.com/bedrockio/yada#reject)
37
+ * @returns {this}
38
+ */
39
+ reject(...set: any[]): this;
40
+ /**
41
+ * @returns {this}
13
42
  */
14
- custom(...args: CustomSignature): Schema;
15
- strip(strip: any): Schema;
16
- allow(...set: any[]): Schema;
17
- reject(...set: any[]): Schema;
18
- message(message: any): Schema;
19
- tag(tags: any): Schema;
20
- description(description: any): Schema;
21
- options(options: any): Schema;
43
+ message(message: any): this;
44
+ /**
45
+ * @returns {this}
46
+ */
47
+ tag(tags: any): this;
48
+ /**
49
+ * @returns {this}
50
+ */
51
+ description(description: any): this;
52
+ /**
53
+ * @returns {this}
54
+ */
55
+ options(options: any): this;
22
56
  validate(value: any, options?: {}): Promise<any>;
23
57
  /**
24
58
  * @returns {this}
25
59
  */
26
60
  clone(meta: any): this;
27
61
  /**
28
- * @returns {Schema}
62
+ * Appends another schema. [Link](https://github.com/bedrockio/yada#append)
63
+ * @returns {this}
29
64
  */
30
- append(schema: any): Schema;
65
+ append(schema: any): this;
31
66
  toOpenApi(extra: any): any;
32
- assertEnum(set: any, allow: any): Schema;
33
- assert(type: any, fn: any): Schema;
67
+ /**
68
+ * @returns {this}
69
+ */
70
+ assertEnum(set: any, allow: any): this;
71
+ /**
72
+ * @returns {this}
73
+ */
74
+ assert(type: any, fn: any): this;
34
75
  pushAssertion(assertion: any): void;
35
- transform(fn: any): Schema;
76
+ /**
77
+ * @returns {this}
78
+ */
79
+ transform(fn: any): this;
36
80
  getSortIndex(type: any): number;
37
81
  runAssertion(assertion: any, value: any, options?: {}): Promise<any>;
38
82
  enumToOpenApi(): {
@@ -1 +1 @@
1
- {"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../src/Schema.js"],"names":[],"mappings":"AAgSA,4CAEC;AAvRD;;GAEG;AAEH;IACE,uBAGC;IAFC,kBAAoB;IACpB,SAAgB;IAKlB,mBAMC;IAED,4BAMC;IAED;;OAEG;IACH,gBAFW,eAAe,UAmBzB;IAED,0BAEC;IAED,6BAEC;IAED,8BAEC;IAED,8BAEC;IAED,uBAOC;IAED,sCAIC;IAED,8BAEC;IAED,iDAqCC;IAED;;OAEG;IACH,kBAFa,IAAI,CAOhB;IAED;;OAEG;IACH,qBAFa,MAAM,CAMlB;IAED,2BAgBC;IAID,yCA8BC;IAED,mCAQC;IAED,oCAKC;IAED,2BAOC;IAED,gCAGC;IAED,qEAUC;IAED;;;;;;;;MAoCC;CACF;8BAlRY,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC"}
1
+ {"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../src/Schema.js"],"names":[],"mappings":"AA4UA,4CAEC;AAnUD;;GAEG;AAEH;IACE,uBAGC;IAFC,kBAAoB;IACpB,SAAgB;IAKlB;;OAEG;IACH,YAFa,IAAI,CAQhB;IAED;;;OAGG;IACH,qBAFa,IAAI,CAQhB;IAED;;;;OAIG;IACH,gBAHW,eAAe,GACb,IAAI,CAmBhB;IAED;;;;OAIG;IACH,mBAFa,IAAI,CAIhB;IAED;;;OAGG;IACH,sBAFa,IAAI,CAIhB;IAED;;;OAGG;IACH,uBAFa,IAAI,CAIhB;IAED;;OAEG;IACH,uBAFa,IAAI,CAIhB;IAED;;OAEG;IACH,gBAFa,IAAI,CAShB;IAED;;OAEG;IACH,+BAFa,IAAI,CAMhB;IAED;;OAEG;IACH,uBAFa,IAAI,CAIhB;IAED,iDAqCC;IAED;;OAEG;IACH,kBAFa,IAAI,CAOhB;IAED;;;OAGG;IACH,qBAFa,IAAI,CAMhB;IAED,2BAgBC;IAID;;OAEG;IACH,kCAFa,IAAI,CAgChB;IAED;;OAEG;IACH,4BAFa,IAAI,CAUhB;IAED,oCAKC;IAED;;OAEG;IACH,oBAFa,IAAI,CAShB;IAED,gCAGC;IAED,qEAUC;IAED;;;;;;;;MAoCC;CACF;8BA9TY,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC"}
package/types/array.d.ts CHANGED
@@ -1,11 +1,15 @@
1
- declare const _default: {
2
- (...schemas: Schema[]): ArraySchema;
3
- (schemas: Schema[]): ArraySchema;
4
- };
5
- export default _default;
1
+ /**
2
+ * Creates an [array schema](https://github.com/bedrockio/yada#array).
3
+ *
4
+ * @param {...Schema} [schemas] Optional schemas to validate
5
+ * the different types of elements allowed in the array. If
6
+ * no arguments are passed elements may be of any type. Also
7
+ * accepts a single array argument.
8
+ */
9
+ export default function _default(...schemas?: Schema[]): ArraySchema;
6
10
  import Schema from "./Schema";
7
11
  declare class ArraySchema extends Schema {
8
- constructor(...args: any[]);
12
+ constructor(schemas: any);
9
13
  /**
10
14
  * @private
11
15
  */
@@ -15,4 +19,5 @@ declare class ArraySchema extends Schema {
15
19
  max(length: any): ArraySchema;
16
20
  latlng(): ArraySchema;
17
21
  }
22
+ export {};
18
23
  //# sourceMappingURL=array.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../src/array.js"],"names":[],"mappings":";iBAmJkB,MAAM,EAAE,GAAI,WAAW;cAC1B,MAAM,EAAE,GAAI,WAAW;;;;AAhJtC;IACE,4BAYC;IAED;;OAEG;IACH,cAwCC;IAED,iCAUC;IAED,8BAUC;IAED,8BAaC;IAED,sBAaC;CA2BF"}
1
+ {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../src/array.js"],"names":[],"mappings":"AAuIA;;;;;;;GAOG;AACH,8CALc,MAAM,iBAUnB;;AAjJD;IACE,0BAGC;IAED;;OAEG;IACH,cAwCC;IAED,iCAUC;IAED,8BAUC;IAED,8BAaC;IAED,sBAaC;CA2BF"}
@@ -1,7 +1,10 @@
1
- declare const _default: () => BooleanSchema;
2
- export default _default;
1
+ /**
2
+ * Creates a [boolean schema](https://github.com/bedrockio/yada#boolean).
3
+ */
4
+ export default function _default(): BooleanSchema;
3
5
  declare class BooleanSchema extends TypeSchema {
4
6
  constructor();
5
7
  }
6
8
  import TypeSchema from "./TypeSchema";
9
+ export {};
7
10
  //# sourceMappingURL=boolean.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../src/boolean.js"],"names":[],"mappings":"8BAyBsB,aAAa;;AArBnC;IACE,cAgBC;CACF"}
1
+ {"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../src/boolean.js"],"names":[],"mappings":"AAuBA;;GAEG;AACH,kDAEC;AAzBD;IACE,cAgBC;CACF"}
package/types/date.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- declare const _default: () => DateSchema;
2
- export default _default;
1
+ /**
2
+ * Creates a [date schema](https://github.com/bedrockio/yada#date).
3
+ */
4
+ export default function _default(): DateSchema;
3
5
  declare class DateSchema extends Schema {
4
6
  constructor();
5
7
  /**
@@ -28,4 +30,5 @@ declare class DateSchema extends Schema {
28
30
  unix(): DateSchema;
29
31
  }
30
32
  import Schema from "./Schema";
33
+ export {};
31
34
  //# sourceMappingURL=date.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../src/date.js"],"names":[],"mappings":"wBAqJU,MAAM,UAAU;;AA/I1B;IACE,cAUC;IAED;;OAEG;IACH,SAFW,MAAM,GAAC,MAAM,GAAC,IAAI,cAY5B;IAED;;OAEG;IACH,SAFW,MAAM,GAAC,MAAM,GAAC,IAAI,cAY5B;IAED;;OAEG;IACH,YAFW,MAAM,GAAC,MAAM,GAAC,IAAI,cAY5B;IAED;;OAEG;IACH,WAFW,MAAM,GAAC,MAAM,GAAC,IAAI,cAY5B;IAED,mBAOC;IAED,qBAOC;IAED;;OAEG;IACH,aAFW,MAAM,GAAG,WAAW,cAW9B;IAED,wBASC;IAED,mBAWC;CAaF"}
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../src/date.js"],"names":[],"mappings":"AAmJA;;GAEG;AACH,+CAEC;AAnJD;IACE,cAUC;IAED;;OAEG;IACH,SAFW,MAAM,GAAC,MAAM,GAAC,IAAI,cAY5B;IAED;;OAEG;IACH,SAFW,MAAM,GAAC,MAAM,GAAC,IAAI,cAY5B;IAED;;OAEG;IACH,YAFW,MAAM,GAAC,MAAM,GAAC,IAAI,cAY5B;IAED;;OAEG;IACH,WAFW,MAAM,GAAC,MAAM,GAAC,IAAI,cAY5B;IAED,mBAOC;IAED,qBAOC;IAED;;OAEG;IACH,aAFW,MAAM,GAAG,WAAW,cAW9B;IAED,wBASC;IAED,mBAWC;CAaF"}
package/types/index.d.ts CHANGED
@@ -22,10 +22,20 @@ import date from "./date";
22
22
  import number from "./number";
23
23
  import object from "./object";
24
24
  import string from "./string";
25
+ /**
26
+ * Accepts anything.
27
+ */
25
28
  export function any(): Schema;
29
+ /**
30
+ * Accept values or schemas. [Link](https://github.com/bedrockio/yada#allow)
31
+ */
26
32
  export function allow(...args: any[]): Schema;
33
+ /**
34
+ * Reject values or schemas. [Link](https://github.com/bedrockio/yada#reject)
35
+ */
27
36
  export function reject(...args: any[]): Schema;
28
37
  /**
38
+ * Validate by a custom function. [Link](https://github.com/bedrockio/yada#custom)
29
39
  * @param {import("./Schema").CustomSignature} args
30
40
  */
31
41
  export function custom(...args: import("./Schema").CustomSignature): Schema;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAYA,8BAEC;AAED,8CAEC;AAED,+CAEC;AAED;;GAEG;AACH,gCAFW,OAAO,UAAU,EAAE,eAAe,UAI5C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAYA;;GAEG;AACH,8BAEC;AAED;;GAEG;AACH,8CAEC;AAED;;GAEG;AACH,+CAEC;AAED;;;GAGG;AACH,gCAFW,OAAO,UAAU,EAAE,eAAe,UAI5C"}
package/types/number.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- declare const _default: () => NumberSchema;
2
- export default _default;
1
+ /**
2
+ * Creates a [number schema](https://github.com/bedrockio/yada#number).
3
+ */
4
+ export default function _default(): NumberSchema;
3
5
  declare class NumberSchema extends TypeSchema {
4
6
  constructor();
5
7
  /**
@@ -18,4 +20,5 @@ declare class NumberSchema extends TypeSchema {
18
20
  multiple(multiple: any): NumberSchema;
19
21
  }
20
22
  import TypeSchema from "./TypeSchema";
23
+ export {};
21
24
  //# sourceMappingURL=number.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/number.js"],"names":[],"mappings":"wBA0FU,MAAM,YAAY;;AAtF5B;IACE,cAWC;IAED;;;OAGG;IACH,SAHW,MAAM,YACN,MAAM,gBAUhB;IAED;;;OAGG;IACH,SAHW,MAAM,YACN,MAAM,gBAUhB;IAED,yBAEC;IAED,yBAEC;IAED,wBAMC;IAED,sCAQC;CAiBF"}
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/number.js"],"names":[],"mappings":"AAwFA;;GAEG;AACH,iDAEC;AA1FD;IACE,cAWC;IAED;;;OAGG;IACH,SAHW,MAAM,YACN,MAAM,gBAUhB;IAED;;;OAGG;IACH,SAHW,MAAM,YACN,MAAM,gBAUhB;IAED,yBAEC;IAED,yBAEC;IAED,wBAMC;IAED,sCAQC;CAiBF"}
package/types/object.d.ts CHANGED
@@ -1,5 +1,17 @@
1
- declare const _default: (arg: object) => ObjectSchema;
2
- export default _default;
1
+ /**
2
+ * Creates an [object schema](https://github.com/bedrockio/yada#object).
3
+ *
4
+ * @param {SchemaMap} [map] An map of keys to schemas.
5
+ * If not passed any object shape will be allowed. If an
6
+ * empty object is passed then no keys will be allowed.
7
+ */
8
+ export default function _default(map?: SchemaMap): ObjectSchema;
9
+ export type SchemaMap = {} | {
10
+ [key: string]: Schema;
11
+ };
12
+ /**
13
+ * @typedef {{ [key: string]: Schema } | {}} SchemaMap
14
+ */
3
15
  declare class ObjectSchema extends TypeSchema {
4
16
  constructor(fields: any);
5
17
  /**
@@ -7,11 +19,15 @@ declare class ObjectSchema extends TypeSchema {
7
19
  */
8
20
  private setup;
9
21
  /**
10
- * @param {object|ObjectSchema} arg
11
- * @returns Schema
22
+ * @private
23
+ */
24
+ private getFields;
25
+ /**
26
+ * @param {SchemaMap|Schema} arg Object or schema to append.
12
27
  */
13
- append(arg: object | ObjectSchema): any;
14
- getFields(): any;
28
+ append(arg: SchemaMap | Schema): ObjectSchema;
15
29
  }
30
+ import Schema from "./Schema";
16
31
  import TypeSchema from "./TypeSchema";
32
+ export {};
17
33
  //# sourceMappingURL=object.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../src/object.js"],"names":[],"mappings":"8BAsIgB,MAAM,KAAK,YAAY;;AA/HvC;IACE,yBAGC;IAED;;OAEG;IACH,cA+DC;IAED;;;OAGG;IACH,YAHW,MAAM,GAAC,YAAY,OA+B7B;IAED,iBAEC;CAcF"}
1
+ {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../src/object.js"],"names":[],"mappings":"AA2IA;;;;;;GAMG;AACH,uCAJW,SAAS,gBAMnB;;;;AA9ID;;GAEG;AAEH;IACE,yBAGC;IAED;;OAEG;IACH,cA+DC;IAED;;OAEG;IACH,kBAEC;IAED;;OAEG;IAEH,YAHW,SAAS,GAAC,MAAM,gBA+B1B;CAcF"}
package/types/string.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- declare const _default: () => StringSchema;
2
- export default _default;
1
+ /**
2
+ * Creates a [string schema](https://github.com/bedrockio/yada#string).
3
+ */
4
+ export default function _default(): StringSchema;
3
5
  declare class StringSchema extends TypeSchema {
4
6
  constructor();
5
7
  /**
@@ -30,7 +32,7 @@ declare class StringSchema extends TypeSchema {
30
32
  sha1(): StringSchema;
31
33
  ascii(): StringSchema;
32
34
  /**
33
- * @param {Object} [options]
35
+ * @param {object} [options]
34
36
  * @param {boolean} [options.urlSafe]
35
37
  */
36
38
  base64(options?: {
@@ -48,7 +50,7 @@ declare class StringSchema extends TypeSchema {
48
50
  */
49
51
  postalCode(locale?: string): StringSchema;
50
52
  /**
51
- * @param {Object} [options]
53
+ * @param {object} [options]
52
54
  * @param {number} [options.minLength]
53
55
  * @param {number} [options.minNumbers]
54
56
  * @param {number} [options.minSymbols]
@@ -63,7 +65,7 @@ declare class StringSchema extends TypeSchema {
63
65
  minUppercase?: number;
64
66
  }): StringSchema;
65
67
  /**
66
- * @param {Object} [options]
68
+ * @param {object} [options]
67
69
  * @param {boolean} [options.require_protocol]
68
70
  * @param {boolean} [options.require_valid_protocol]
69
71
  * @param {boolean} [options.require_host]
@@ -86,7 +88,7 @@ declare class StringSchema extends TypeSchema {
86
88
  protocols?: string[];
87
89
  }): StringSchema;
88
90
  /**
89
- * @param {Object} [options]
91
+ * @param {object} [options]
90
92
  * @param {boolean} [options.require_tld=true]
91
93
  * @param {boolean} [options.allow_underscores=false]
92
94
  * @param {boolean} [options.allow_trailing_dot=false]
@@ -112,4 +114,5 @@ declare class StringSchema extends TypeSchema {
112
114
  mongo(): StringSchema;
113
115
  }
114
116
  import TypeSchema from "./TypeSchema";
117
+ export {};
115
118
  //# sourceMappingURL=string.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.js"],"names":[],"mappings":"wBA8WU,MAAM,YAAY;;AA9V5B;IACE,cAWC;IAED;;OAEG;IACH,YAFW,MAAM,gBAUhB;IAED;;OAEG;IACH,YAFW,MAAM,gBAUhB;IAED,qBAIC;IAED;;OAEG;IACH,mBAFW,OAAO,gBAYjB;IAED;;OAEG;IACH,mBAFW,OAAO,gBAYjB;IAED;;OAEG;IACH,WAFW,MAAM,gBAahB;IAED,sBAMC;IAED,sBAMC;IAED,oBAMC;IAED,oBAMC;IAED,qBAMC;IAED,sBAMC;IAED;;;OAGG;IACH;QAF6B,OAAO,GAAzB,OAAO;qBAQjB;IAED,2BAMC;IAED,mBAMC;IAED,wBAMC;IAED,uBAMC;IAED,oBAMC;IAED,qBAOC;IAED,uBAMC;IAED;;OAEG;IACH,oBAFW,MAAM,gBAQhB;IAED;;;;;;;OAOG;IACH;QAN4B,SAAS,GAA1B,MAAM;QACW,UAAU,GAA3B,MAAM;QACW,UAAU,GAA3B,MAAM;QACW,YAAY,GAA7B,MAAM;QACW,YAAY,GAA7B,MAAM;qBA2BhB;IAED;;;;;;;;;;;OAWG;IACH;QAV6B,gBAAgB,GAAlC,OAAO;QACW,sBAAsB,GAAxC,OAAO;QACW,YAAY,GAA9B,OAAO;QACW,YAAY,GAA9B,OAAO;QACW,4BAA4B,GAA9C,OAAO;QACW,eAAe,GAAjC,OAAO;QACW,sBAAsB,GAAxC,OAAO;QACW,eAAe,GAAjC,OAAO;QACY,SAAS,GAA5B,MAAM,EAAE;qBAQlB;IAED;;;;;;;;OAQG;IACH;QAP6B,WAAW,GAA7B,OAAO;QACW,iBAAiB,GAAnC,OAAO;QACW,kBAAkB,GAApC,OAAO;QACW,iBAAiB,GAAnC,OAAO;QACW,cAAc,GAAhC,OAAO;QACW,iBAAiB,GAAnC,OAAO;qBAQjB;IAED;;OAEG;IACH,eAFW,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,gBAQ3B;IAED,oBAMC;IAED,oBAMC;IAED,sBAMC;IAED,sBAMC;CAcF"}
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.js"],"names":[],"mappings":"AA4WA;;GAEG;AACH,iDAEC;AAlWD;IACE,cAWC;IAED;;OAEG;IACH,YAFW,MAAM,gBAUhB;IAED;;OAEG;IACH,YAFW,MAAM,gBAUhB;IAED,qBAIC;IAED;;OAEG;IACH,mBAFW,OAAO,gBAYjB;IAED;;OAEG;IACH,mBAFW,OAAO,gBAYjB;IAED;;OAEG;IACH,WAFW,MAAM,gBAahB;IAED,sBAMC;IAED,sBAMC;IAED,oBAMC;IAED,oBAMC;IAED,qBAMC;IAED,sBAMC;IAED;;;OAGG;IACH;QAF6B,OAAO,GAAzB,OAAO;qBAQjB;IAED,2BAMC;IAED,mBAMC;IAED,wBAMC;IAED,uBAMC;IAED,oBAMC;IAED,qBAOC;IAED,uBAMC;IAED;;OAEG;IACH,oBAFW,MAAM,gBAQhB;IAED;;;;;;;OAOG;IACH;QAN4B,SAAS,GAA1B,MAAM;QACW,UAAU,GAA3B,MAAM;QACW,UAAU,GAA3B,MAAM;QACW,YAAY,GAA7B,MAAM;QACW,YAAY,GAA7B,MAAM;qBA2BhB;IAED;;;;;;;;;;;OAWG;IACH;QAV6B,gBAAgB,GAAlC,OAAO;QACW,sBAAsB,GAAxC,OAAO;QACW,YAAY,GAA9B,OAAO;QACW,YAAY,GAA9B,OAAO;QACW,4BAA4B,GAA9C,OAAO;QACW,eAAe,GAAjC,OAAO;QACW,sBAAsB,GAAxC,OAAO;QACW,eAAe,GAAjC,OAAO;QACY,SAAS,GAA5B,MAAM,EAAE;qBAQlB;IAED;;;;;;;;OAQG;IACH;QAP6B,WAAW,GAA7B,OAAO;QACW,iBAAiB,GAAnC,OAAO;QACW,kBAAkB,GAApC,OAAO;QACW,iBAAiB,GAAnC,OAAO;QACW,cAAc,GAAhC,OAAO;QACW,iBAAiB,GAAnC,OAAO;qBAQjB;IAED;;OAEG;IACH,eAFW,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,gBAQ3B;IAED,oBAMC;IAED,oBAMC;IAED,sBAMC;IAED,sBAMC;CAcF"}
package/types/utils.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export function wrapSchema(Class: any): (...args: any[]) => any;
2
1
  export { isSchema } from "./Schema";
3
2
  export { isSchemaError } from "./errors";
4
3
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAAA,gEAIC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":""}