@bedrockio/yada 1.0.13 → 1.0.14

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.
Files changed (53) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/Schema.js +47 -24
  3. package/dist/cjs/TypeSchema.js +1 -2
  4. package/dist/cjs/array.js +12 -2
  5. package/dist/cjs/boolean.js +5 -2
  6. package/dist/cjs/date.js +29 -2
  7. package/dist/cjs/index.js +89 -7
  8. package/dist/cjs/localization.js +31 -15
  9. package/dist/cjs/number.js +19 -8
  10. package/dist/cjs/object.js +14 -2
  11. package/dist/cjs/string.js +73 -5
  12. package/dist/cjs/utils.js +1 -15
  13. package/package.json +8 -5
  14. package/src/Schema.js +39 -20
  15. package/src/array.js +9 -0
  16. package/src/boolean.js +3 -0
  17. package/src/date.js +22 -0
  18. package/src/index.js +40 -7
  19. package/src/localization.js +28 -14
  20. package/src/number.js +15 -6
  21. package/src/object.js +10 -0
  22. package/src/string.js +58 -1
  23. package/src/utils.js +0 -14
  24. package/types/Schema.d.ts +49 -0
  25. package/types/Schema.d.ts.map +1 -0
  26. package/types/TypeSchema.d.ts +7 -0
  27. package/types/TypeSchema.d.ts.map +1 -0
  28. package/types/array.d.ts +18 -0
  29. package/types/array.d.ts.map +1 -0
  30. package/types/boolean.d.ts +7 -0
  31. package/types/boolean.d.ts.map +1 -0
  32. package/types/date.d.ts +31 -0
  33. package/types/date.d.ts.map +1 -0
  34. package/types/errors.d.ts +54 -0
  35. package/types/errors.d.ts.map +1 -0
  36. package/types/index.d.ts +39 -0
  37. package/types/index.d.ts.map +1 -0
  38. package/types/localization.d.ts +19 -0
  39. package/types/localization.d.ts.map +1 -0
  40. package/types/messages.d.ts +2 -0
  41. package/types/messages.d.ts.map +1 -0
  42. package/types/number.d.ts +21 -0
  43. package/types/number.d.ts.map +1 -0
  44. package/types/object.d.ts +17 -0
  45. package/types/object.d.ts.map +1 -0
  46. package/types/password.d.ts +13 -0
  47. package/types/password.d.ts.map +1 -0
  48. package/types/string.d.ts +115 -0
  49. package/types/string.d.ts.map +1 -0
  50. package/types/utils.d.ts +4 -0
  51. package/types/utils.d.ts.map +1 -0
  52. package/.eslintignore +0 -1
  53. package/test/all.test.js +0 -1989
package/README.md CHANGED
@@ -607,7 +607,7 @@ yd.useLocalizer((template) => {
607
607
  Any validation message matching the keys passed to the map will result in the
608
608
  localized message instead. The curly braces allow for variable substitution.
609
609
 
610
- A special method `getLocalizerTemplates` will aggregte used error messages to
610
+ A special method `getLocalizedMessages` will aggregte used error messages to
611
611
  allow quick discovery of strings that have not yet been localized:
612
612
 
613
613
  ```js
@@ -616,7 +616,7 @@ yd.useLocalizer({
616
616
  'Object failed validation.': '不正な入力がありました。',
617
617
  });
618
618
  // Error validation occuring here
619
- yd.getLocalizedTemplates();
619
+ yd.getLocalizedMessages();
620
620
  // {
621
621
  // 'Must be at least {length} character{s}.': '{length}文字以上入力して下さい。',
622
622
  // 'Object failed validation.': '不正な入力がありました。',
@@ -685,7 +685,7 @@ Basic utility methods:
685
685
  - `isSchema`: returns `true` if the object passed is a schema.
686
686
  - `isSchemaError`: returns `true` if the error object is a schema error.
687
687
  - `useLocalizer`: Allows [localization](#localization) of error messages.
688
- - `getLocalizerTemplates`: Allows discovery of messages for
688
+ - `getLocalizedMessages`: Allows discovery of messages for
689
689
  [localization](#localization).
690
690
  - `LocalizedError`: An error object that can be thrown in custom validations to
691
691
  allow [localization](#localization).
@@ -8,6 +8,11 @@ exports.isSchema = isSchema;
8
8
  var _errors = require("./errors");
9
9
  const INITIAL_TYPES = ['default', 'required', 'type', 'transform'];
10
10
  const REQUIRED_TYPES = ['default', 'required'];
11
+
12
+ /**
13
+ * @typedef {[fn: Function] | [type: string, fn: Function]} CustomSignature
14
+ */
15
+
11
16
  class Schema {
12
17
  constructor(meta = {}) {
13
18
  this.assertions = [];
@@ -34,9 +39,19 @@ class Schema {
34
39
  }
35
40
  });
36
41
  }
42
+
43
+ /**
44
+ * @param {CustomSignature} args
45
+ */
37
46
  custom(...args) {
38
- const type = args.length > 1 ? args[0] : 'custom';
39
- const fn = args.length > 1 ? args[1] : args[0];
47
+ let type, fn;
48
+ if (typeof args[0] === 'function') {
49
+ type = 'custom';
50
+ fn = args[0];
51
+ } else {
52
+ type = args[0];
53
+ fn = args[1];
54
+ }
40
55
  if (!type) {
41
56
  throw new Error('Assertion type required.');
42
57
  } else if (!fn) {
@@ -116,6 +131,10 @@ class Schema {
116
131
  }
117
132
  return value;
118
133
  }
134
+
135
+ /**
136
+ * @returns {this}
137
+ */
119
138
  clone(meta) {
120
139
  const clone = Object.create(this.constructor.prototype);
121
140
  clone.assertions = [...this.assertions];
@@ -125,11 +144,37 @@ class Schema {
125
144
  };
126
145
  return clone;
127
146
  }
147
+
148
+ /**
149
+ * @returns {Schema}
150
+ */
128
151
  append(schema) {
129
152
  const merged = this.clone(schema.meta);
130
153
  merged.assertions = [...this.assertions, ...schema.assertions];
131
154
  return merged;
132
155
  }
156
+ toOpenApi(extra) {
157
+ const {
158
+ required,
159
+ format,
160
+ tags,
161
+ default: defaultValue
162
+ } = this.meta;
163
+ return {
164
+ ...(required && {
165
+ required: true
166
+ }),
167
+ ...(defaultValue && {
168
+ default: defaultValue
169
+ }),
170
+ ...(format && {
171
+ format
172
+ }),
173
+ ...this.enumToOpenApi(),
174
+ ...tags,
175
+ ...extra
176
+ };
177
+ }
133
178
 
134
179
  // Private
135
180
 
@@ -207,28 +252,6 @@ class Schema {
207
252
  throw new _errors.AssertionError(error.message, error.type || type, error);
208
253
  }
209
254
  }
210
- toOpenApi(extra) {
211
- const {
212
- required,
213
- format,
214
- tags,
215
- default: defaultValue
216
- } = this.meta;
217
- return {
218
- ...(required && {
219
- required: true
220
- }),
221
- ...(defaultValue && {
222
- default: defaultValue
223
- }),
224
- ...(format && {
225
- format
226
- }),
227
- ...this.enumToOpenApi(),
228
- ...tags,
229
- ...extra
230
- };
231
- }
232
255
  enumToOpenApi() {
233
256
  const {
234
257
  enum: allowed
@@ -29,5 +29,4 @@ class TypeSchema extends _Schema.default {
29
29
  };
30
30
  }
31
31
  }
32
- exports.default = TypeSchema;
33
- module.exports = exports.default;
32
+ exports.default = TypeSchema;
package/dist/cjs/array.js CHANGED
@@ -24,6 +24,10 @@ class ArraySchema extends _Schema.default {
24
24
  });
25
25
  this.setup();
26
26
  }
27
+
28
+ /**
29
+ * @private
30
+ */
27
31
  setup() {
28
32
  const {
29
33
  schemas
@@ -137,6 +141,12 @@ class ArraySchema extends _Schema.default {
137
141
  };
138
142
  }
139
143
  }
144
+
145
+ /**
146
+ * @type {{
147
+ * (...schemas: Schema[]) : ArraySchema;
148
+ * (schemas: Schema[]) : ArraySchema;
149
+ * }}
150
+ */
140
151
  var _default = (0, _utils.wrapSchema)(ArraySchema);
141
- exports.default = _default;
142
- module.exports = exports.default;
152
+ exports.default = _default;
@@ -27,6 +27,9 @@ class BooleanSchema extends _TypeSchema.default {
27
27
  });
28
28
  }
29
29
  }
30
+
31
+ /**
32
+ * @type {function(): BooleanSchema}
33
+ */
30
34
  var _default = (0, _utils.wrapSchema)(BooleanSchema);
31
- exports.default = _default;
32
- module.exports = exports.default;
35
+ exports.default = _default;
package/dist/cjs/date.js CHANGED
@@ -21,41 +21,61 @@ class DateSchema extends _Schema.default {
21
21
  }
22
22
  });
23
23
  }
24
+
25
+ /**
26
+ * @param {string|number|Date} min
27
+ */
24
28
  min(min) {
25
29
  min = new Date(min);
26
30
  return this.clone().assert('min', date => {
27
31
  if (date < min) {
28
32
  throw new _errors.LocalizedError('Must be after {date}.', {
33
+ // @ts-ignore
29
34
  date: min.toISOString()
30
35
  });
31
36
  }
32
37
  });
33
38
  }
39
+
40
+ /**
41
+ * @param {string|number|Date} max
42
+ */
34
43
  max(max) {
35
44
  max = new Date(max);
36
45
  return this.clone().assert('max', date => {
37
46
  if (date > max) {
38
47
  throw new _errors.LocalizedError('Must be before {date}.', {
48
+ // @ts-ignore
39
49
  date: max.toISOString()
40
50
  });
41
51
  }
42
52
  });
43
53
  }
54
+
55
+ /**
56
+ * @param {string|number|Date} max
57
+ */
44
58
  before(max) {
45
59
  max = new Date(max);
46
60
  return this.clone().assert('before', date => {
47
61
  if (date >= max) {
48
62
  throw new _errors.LocalizedError('Must be before {date}.', {
63
+ // @ts-ignore
49
64
  date: max.toISOString()
50
65
  });
51
66
  }
52
67
  });
53
68
  }
69
+
70
+ /**
71
+ * @param {string|number|Date} min
72
+ */
54
73
  after(min) {
55
74
  min = new Date(min);
56
75
  return this.clone().assert('after', date => {
57
76
  if (date <= min) {
58
77
  throw new _errors.LocalizedError('Must be after {date}.', {
78
+ // @ts-ignore
59
79
  date: min.toISOString()
60
80
  });
61
81
  }
@@ -77,6 +97,10 @@ class DateSchema extends _Schema.default {
77
97
  }
78
98
  });
79
99
  }
100
+
101
+ /**
102
+ * @param {"date" | "date-time"} format
103
+ */
80
104
  iso(format = 'date-time') {
81
105
  return this.clone({
82
106
  format
@@ -128,6 +152,9 @@ class DateSchema extends _Schema.default {
128
152
  };
129
153
  }
130
154
  }
155
+
156
+ /**
157
+ * @type {() => DateSchema}
158
+ */
131
159
  var _default = (0, _utils.wrapSchema)(DateSchema);
132
- exports.default = _default;
133
- module.exports = exports.default;
160
+ exports.default = _default;
package/dist/cjs/index.js CHANGED
@@ -3,21 +3,104 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "LocalizedError", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _errors.LocalizedError;
10
+ }
11
+ });
12
+ exports.allow = allow;
13
+ exports.any = any;
14
+ Object.defineProperty(exports, "array", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _array.default;
18
+ }
19
+ });
20
+ Object.defineProperty(exports, "boolean", {
21
+ enumerable: true,
22
+ get: function () {
23
+ return _boolean.default;
24
+ }
25
+ });
26
+ exports.custom = custom;
27
+ Object.defineProperty(exports, "date", {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _date.default;
31
+ }
32
+ });
6
33
  exports.default = void 0;
34
+ Object.defineProperty(exports, "getLocalizedMessages", {
35
+ enumerable: true,
36
+ get: function () {
37
+ return _localization.getLocalizedMessages;
38
+ }
39
+ });
40
+ Object.defineProperty(exports, "isSchema", {
41
+ enumerable: true,
42
+ get: function () {
43
+ return _utils.isSchema;
44
+ }
45
+ });
46
+ Object.defineProperty(exports, "isSchemaError", {
47
+ enumerable: true,
48
+ get: function () {
49
+ return _utils.isSchemaError;
50
+ }
51
+ });
52
+ Object.defineProperty(exports, "number", {
53
+ enumerable: true,
54
+ get: function () {
55
+ return _number.default;
56
+ }
57
+ });
58
+ Object.defineProperty(exports, "object", {
59
+ enumerable: true,
60
+ get: function () {
61
+ return _object.default;
62
+ }
63
+ });
64
+ exports.reject = reject;
65
+ Object.defineProperty(exports, "string", {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _string.default;
69
+ }
70
+ });
71
+ Object.defineProperty(exports, "useLocalizer", {
72
+ enumerable: true,
73
+ get: function () {
74
+ return _localization.useLocalizer;
75
+ }
76
+ });
7
77
  var _array = _interopRequireDefault(require("./array"));
8
78
  var _boolean = _interopRequireDefault(require("./boolean"));
9
79
  var _date = _interopRequireDefault(require("./date"));
10
80
  var _number = _interopRequireDefault(require("./number"));
11
81
  var _object = _interopRequireDefault(require("./object"));
12
82
  var _string = _interopRequireDefault(require("./string"));
83
+ var _Schema = _interopRequireDefault(require("./Schema"));
13
84
  var _utils = require("./utils");
14
85
  var _localization = require("./localization");
15
86
  var _errors = require("./errors");
16
87
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
- const allow = (0, _utils.wrapArgs)('allow');
18
- const reject = (0, _utils.wrapArgs)('reject');
19
- const custom = (0, _utils.wrapArgs)('custom');
20
- const any = (0, _utils.wrapAny)();
88
+ function any() {
89
+ return new _Schema.default();
90
+ }
91
+ function allow(...args) {
92
+ return new _Schema.default().allow(...args);
93
+ }
94
+ function reject(...args) {
95
+ return new _Schema.default().reject(...args);
96
+ }
97
+
98
+ /**
99
+ * @param {import("./Schema").CustomSignature} args
100
+ */
101
+ function custom(...args) {
102
+ return new _Schema.default().custom(...args);
103
+ }
21
104
  var _default = {
22
105
  array: _array.default,
23
106
  boolean: _boolean.default,
@@ -32,8 +115,7 @@ var _default = {
32
115
  isSchema: _utils.isSchema,
33
116
  isSchemaError: _utils.isSchemaError,
34
117
  useLocalizer: _localization.useLocalizer,
35
- getLocalizerTemplates: _localization.getLocalizerTemplates,
118
+ getLocalizedMessages: _localization.getLocalizedMessages,
36
119
  LocalizedError: _errors.LocalizedError
37
120
  };
38
- exports.default = _default;
39
- module.exports = exports.default;
121
+ exports.default = _default;
@@ -4,38 +4,54 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getLocalized = getLocalized;
7
- exports.getLocalizerTemplates = getLocalizerTemplates;
7
+ exports.getLocalizedMessages = getLocalizedMessages;
8
8
  exports.localize = localize;
9
9
  exports.useLocalizer = useLocalizer;
10
10
  const TOKEN_REG = /{(.+?)}/g;
11
11
  let localizer;
12
- let templates = {};
12
+
13
+ /**
14
+ * @type {{ [key: string]: string }}
15
+ */
16
+ let messages = {};
17
+
18
+ /**
19
+ * @param {{ [key: string]: string } | ((key: string) => string)} arg
20
+ * An object that maps messages to localized strings or a function that
21
+ * accepts a message and returns a localized string. Use "getLocalizedMessages"
22
+ * to see the messages that exist.
23
+ */
13
24
  function useLocalizer(arg) {
14
- const fn = typeof arg === 'function' ? arg : template => arg[template];
25
+ const fn = typeof arg === 'function' ? arg : message => arg[message];
15
26
  localizer = fn;
16
- templates = {};
27
+ messages = {};
17
28
  }
18
- function getLocalized(template) {
29
+ function getLocalized(message) {
19
30
  if (localizer) {
20
- return localizer(template);
31
+ return localizer(message);
21
32
  }
22
33
  }
23
- function localize(template, values = {}) {
24
- let message = template;
25
- if (localizer) {
26
- let localized = getLocalized(template);
34
+ function localize(message, values = {}) {
35
+ let str = message;
36
+ if (str) {
37
+ let localized = getLocalized(message);
27
38
  if (typeof localized === 'function') {
28
39
  localized = localized(values);
29
40
  }
30
41
  if (localized) {
31
- message = localized;
42
+ str = localized;
32
43
  }
33
44
  }
34
- templates[template] = message;
35
- return message.replace(TOKEN_REG, (match, token) => {
45
+ messages[message] = str;
46
+ return str.replace(TOKEN_REG, (match, token) => {
36
47
  return token in values ? values[token] : match;
37
48
  });
38
49
  }
39
- function getLocalizerTemplates() {
40
- return templates;
50
+
51
+ /**
52
+ * Returns an object containing all encountered messages
53
+ * mapped to their localizations.
54
+ */
55
+ function getLocalizedMessages() {
56
+ return messages;
41
57
  }
@@ -21,25 +21,33 @@ class NumberSchema extends _TypeSchema.default {
21
21
  return val;
22
22
  });
23
23
  }
24
- min(min, msg) {
25
- msg ||= 'Must be greater than {min}.';
24
+
25
+ /**
26
+ * @param {number} min
27
+ * @param {string} message
28
+ */
29
+ min(min, message = 'Must be greater than {min}.') {
26
30
  return this.clone({
27
31
  min
28
32
  }).assert('min', num => {
29
33
  if (num < min) {
30
- throw new _errors.LocalizedError(msg, {
34
+ throw new _errors.LocalizedError(message, {
31
35
  min
32
36
  });
33
37
  }
34
38
  });
35
39
  }
36
- max(max, msg) {
37
- msg ||= 'Must be less than {max}.';
40
+
41
+ /**
42
+ * @param {number} max
43
+ * @param {string} message
44
+ */
45
+ max(max, message = 'Must be less than {max}.') {
38
46
  return this.clone({
39
47
  max
40
48
  }).assert('max', num => {
41
49
  if (num > max) {
42
- throw new _errors.LocalizedError(msg, {
50
+ throw new _errors.LocalizedError(message, {
43
51
  max
44
52
  });
45
53
  }
@@ -89,6 +97,9 @@ class NumberSchema extends _TypeSchema.default {
89
97
  };
90
98
  }
91
99
  }
100
+
101
+ /**
102
+ * @type {() => NumberSchema}
103
+ */
92
104
  var _default = (0, _utils.wrapSchema)(NumberSchema);
93
- exports.default = _default;
94
- module.exports = exports.default;
105
+ exports.default = _default;
@@ -18,6 +18,10 @@ class ObjectSchema extends _TypeSchema.default {
18
18
  });
19
19
  this.setup();
20
20
  }
21
+
22
+ /**
23
+ * @private
24
+ */
21
25
  setup() {
22
26
  this.assert('type', val => {
23
27
  if (val === null || typeof val !== 'object') {
@@ -85,6 +89,11 @@ class ObjectSchema extends _TypeSchema.default {
85
89
  });
86
90
  }
87
91
  }
92
+
93
+ /**
94
+ * @param {object|ObjectSchema} arg
95
+ * @returns Schema
96
+ */
88
97
  append(arg) {
89
98
  let schema;
90
99
  if (arg instanceof ObjectSchema) {
@@ -128,6 +137,9 @@ class ObjectSchema extends _TypeSchema.default {
128
137
  };
129
138
  }
130
139
  }
140
+
141
+ /**
142
+ * @type {(arg: object) => ObjectSchema}
143
+ */
131
144
  var _default = (0, _utils.wrapSchema)(ObjectSchema);
132
- exports.default = _default;
133
- module.exports = exports.default;
145
+ exports.default = _default;
@@ -25,6 +25,10 @@ class StringSchema extends _TypeSchema.default {
25
25
  return val;
26
26
  });
27
27
  }
28
+
29
+ /**
30
+ * @param {number} length
31
+ */
28
32
  min(length) {
29
33
  return this.clone({
30
34
  min: length
@@ -36,6 +40,10 @@ class StringSchema extends _TypeSchema.default {
36
40
  }
37
41
  });
38
42
  }
43
+
44
+ /**
45
+ * @param {number} length
46
+ */
39
47
  max(length) {
40
48
  return this.clone({
41
49
  max: length
@@ -52,6 +60,10 @@ class StringSchema extends _TypeSchema.default {
52
60
  return str.trim();
53
61
  });
54
62
  }
63
+
64
+ /**
65
+ * @param {boolean} [assert] Throws an error if not lowercase. Default: `false`.
66
+ */
55
67
  lowercase(assert = false) {
56
68
  return this.clone().transform(str => {
57
69
  const lower = str.toLowerCase();
@@ -63,6 +75,10 @@ class StringSchema extends _TypeSchema.default {
63
75
  }
64
76
  });
65
77
  }
78
+
79
+ /**
80
+ * @param {boolean} [assert] Throws an error if not uppercase. Default: `false`.
81
+ */
66
82
  uppercase(assert = false) {
67
83
  return this.clone().transform(str => {
68
84
  const upper = str.toUpperCase();
@@ -74,6 +90,10 @@ class StringSchema extends _TypeSchema.default {
74
90
  }
75
91
  });
76
92
  }
93
+
94
+ /**
95
+ * @param {RegExp} reg
96
+ */
77
97
  match(reg) {
78
98
  if (!(reg instanceof RegExp)) {
79
99
  throw new _errors.LocalizedError('Argument must be a regular expression');
@@ -128,6 +148,11 @@ class StringSchema extends _TypeSchema.default {
128
148
  }
129
149
  });
130
150
  }
151
+
152
+ /**
153
+ * @param {Object} [options]
154
+ * @param {boolean} [options.urlSafe]
155
+ */
131
156
  base64(options) {
132
157
  return this.format('base64', str => {
133
158
  if (!_validator.default.isBase64(str, options)) {
@@ -185,6 +210,10 @@ class StringSchema extends _TypeSchema.default {
185
210
  }
186
211
  });
187
212
  }
213
+
214
+ /**
215
+ * @param {string} locale
216
+ */
188
217
  postalCode(locale = 'any') {
189
218
  return this.format('postal-code', str => {
190
219
  if (!_validator.default.isPostalCode(str, locale)) {
@@ -192,13 +221,22 @@ class StringSchema extends _TypeSchema.default {
192
221
  }
193
222
  });
194
223
  }
224
+
225
+ /**
226
+ * @param {Object} [options]
227
+ * @param {number} [options.minLength]
228
+ * @param {number} [options.minNumbers]
229
+ * @param {number} [options.minSymbols]
230
+ * @param {number} [options.minLowercase]
231
+ * @param {number} [options.minUppercase]
232
+ */
195
233
  password(options = {}) {
196
234
  const {
197
235
  minLength,
198
- minLowercase,
199
- minUppercase,
200
236
  minNumbers,
201
- minSymbols
237
+ minSymbols,
238
+ minLowercase,
239
+ minUppercase
202
240
  } = {
203
241
  ..._password.PASSWORD_DEFAULTS,
204
242
  ...options
@@ -221,6 +259,19 @@ class StringSchema extends _TypeSchema.default {
221
259
  }
222
260
  return schema;
223
261
  }
262
+
263
+ /**
264
+ * @param {Object} [options]
265
+ * @param {boolean} [options.require_protocol]
266
+ * @param {boolean} [options.require_valid_protocol]
267
+ * @param {boolean} [options.require_host]
268
+ * @param {boolean} [options.require_port]
269
+ * @param {boolean} [options.allow_protocol_relative_urls]
270
+ * @param {boolean} [options.allow_fragments]
271
+ * @param {boolean} [options.allow_query_components]
272
+ * @param {boolean} [options.validate_length]
273
+ * @param {string[]} [options.protocols]
274
+ */
224
275
  url(options) {
225
276
  return this.format('url', str => {
226
277
  if (!_validator.default.isURL(str, options)) {
@@ -228,6 +279,16 @@ class StringSchema extends _TypeSchema.default {
228
279
  }
229
280
  });
230
281
  }
282
+
283
+ /**
284
+ * @param {Object} [options]
285
+ * @param {boolean} [options.require_tld=true]
286
+ * @param {boolean} [options.allow_underscores=false]
287
+ * @param {boolean} [options.allow_trailing_dot=false]
288
+ * @param {boolean} [options.allow_numeric_tld=false]
289
+ * @param {boolean} [options.allow_wildcard=false]
290
+ * @param {boolean} [options.ignore_max_length=false]
291
+ */
231
292
  domain(options) {
232
293
  return this.format('domain', str => {
233
294
  if (!_validator.default.isFQDN(str, options)) {
@@ -235,6 +296,10 @@ class StringSchema extends _TypeSchema.default {
235
296
  }
236
297
  });
237
298
  }
299
+
300
+ /**
301
+ * @param {1 | 2 | 3 | 4 | 5} [version] Version of UUID to check.
302
+ */
238
303
  uuid(version) {
239
304
  return this.format('uuid', str => {
240
305
  if (!_validator.default.isUUID(str, version)) {
@@ -286,6 +351,9 @@ class StringSchema extends _TypeSchema.default {
286
351
  };
287
352
  }
288
353
  }
354
+
355
+ /**
356
+ * @type {() => StringSchema}
357
+ */
289
358
  var _default = (0, _utils.wrapSchema)(StringSchema);
290
- exports.default = _default;
291
- module.exports = exports.default;
359
+ exports.default = _default;