@nhtio/validation 0.1.0-master-87fc6cd7 → 0.1.0-master-06559f66
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/README.md +0 -4
- package/index.cjs +81 -21
- package/index.cjs.map +1 -1
- package/index.mjs +81 -21
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/private/patches/fqdn.d.ts +5 -0
- package/private/schemas/datetime.d.ts +1 -1
- package/private/schemas.d.ts +6 -0
package/index.mjs
CHANGED
|
@@ -37170,7 +37170,7 @@ var require_messages = __commonJSMin((exports) => {
|
|
|
37170
37170
|
var require_extend = __commonJSMin((exports) => {
|
|
37171
37171
|
const { assert: assert$23, clone: clone$10 } = require_lib$4();
|
|
37172
37172
|
const Common$19 = require_common();
|
|
37173
|
-
const Messages$
|
|
37173
|
+
const Messages$6 = require_messages();
|
|
37174
37174
|
const internals$21 = {};
|
|
37175
37175
|
exports.type = function(from$2, options) {
|
|
37176
37176
|
const base$3 = Object.getPrototypeOf(from$2);
|
|
@@ -37180,7 +37180,7 @@ var require_extend = __commonJSMin((exports) => {
|
|
|
37180
37180
|
delete def.base;
|
|
37181
37181
|
prototype._definition = def;
|
|
37182
37182
|
const parent = base$3._definition || {};
|
|
37183
|
-
def.messages = Messages$
|
|
37183
|
+
def.messages = Messages$6.merge(parent.messages, def.messages);
|
|
37184
37184
|
def.properties = Object.assign({}, parent.properties, def.properties);
|
|
37185
37185
|
schema$2.type = def.type;
|
|
37186
37186
|
def.flags = Object.assign({}, parent.flags, def.flags);
|
|
@@ -37323,7 +37323,7 @@ var require_manifest = __commonJSMin((exports) => {
|
|
|
37323
37323
|
init_dist();
|
|
37324
37324
|
const { assert: assert$22, clone: clone$9 } = require_lib$4();
|
|
37325
37325
|
const Common$18 = require_common();
|
|
37326
|
-
const Messages$
|
|
37326
|
+
const Messages$5 = require_messages();
|
|
37327
37327
|
const Ref$6 = require_ref();
|
|
37328
37328
|
const Template$5 = require_template();
|
|
37329
37329
|
let Schemas$3;
|
|
@@ -37340,7 +37340,7 @@ var require_manifest = __commonJSMin((exports) => {
|
|
|
37340
37340
|
if (schema$2._preferences) {
|
|
37341
37341
|
desc$1.preferences = clone$9(schema$2._preferences, { shallow: ["messages"] });
|
|
37342
37342
|
delete desc$1.preferences[Common$18.symbols.prefs];
|
|
37343
|
-
if (desc$1.preferences.messages) desc$1.preferences.messages = Messages$
|
|
37343
|
+
if (desc$1.preferences.messages) desc$1.preferences.messages = Messages$5.decompile(desc$1.preferences.messages);
|
|
37344
37344
|
}
|
|
37345
37345
|
if (schema$2._valids) desc$1.allow = schema$2._valids.describe();
|
|
37346
37346
|
if (schema$2._invalids) desc$1.invalid = schema$2._invalids.describe();
|
|
@@ -38621,7 +38621,7 @@ var require_base = __commonJSMin((exports, module) => {
|
|
|
38621
38621
|
const Errors$5 = require_errors();
|
|
38622
38622
|
const Extend$2 = require_extend();
|
|
38623
38623
|
const Manifest$2 = require_manifest();
|
|
38624
|
-
const Messages$
|
|
38624
|
+
const Messages$4 = require_messages();
|
|
38625
38625
|
const Modify = require_modify();
|
|
38626
38626
|
const Ref$4 = require_ref();
|
|
38627
38627
|
const Trace$2 = require_trace();
|
|
@@ -39026,7 +39026,7 @@ var require_base = __commonJSMin((exports, module) => {
|
|
|
39026
39026
|
}
|
|
39027
39027
|
$_createError(code$2, value, local, state, prefs, options = {}) {
|
|
39028
39028
|
const flags = options.flags !== false ? this._flags : {};
|
|
39029
|
-
const messages$3 = options.messages ? Messages$
|
|
39029
|
+
const messages$3 = options.messages ? Messages$4.merge(this._definition.messages, options.messages) : this._definition.messages;
|
|
39030
39030
|
return new Errors$5.Report(code$2, value, local, flags, messages$3, state, prefs);
|
|
39031
39031
|
}
|
|
39032
39032
|
$_getFlag(name$2) {
|
|
@@ -39295,7 +39295,7 @@ var require_any = __commonJSMin((exports, module) => {
|
|
|
39295
39295
|
const { assert: assert$17 } = require_lib$4();
|
|
39296
39296
|
const Base = require_base();
|
|
39297
39297
|
const Common$12 = require_common();
|
|
39298
|
-
const Messages$
|
|
39298
|
+
const Messages$3 = require_messages();
|
|
39299
39299
|
module.exports = Base.extend({
|
|
39300
39300
|
type: "any",
|
|
39301
39301
|
flags: { only: { default: false } },
|
|
@@ -39367,7 +39367,7 @@ var require_any = __commonJSMin((exports, module) => {
|
|
|
39367
39367
|
rule.keep = enabled;
|
|
39368
39368
|
},
|
|
39369
39369
|
message(rule, message) {
|
|
39370
|
-
rule.message = Messages$
|
|
39370
|
+
rule.message = Messages$3.compile(message);
|
|
39371
39371
|
},
|
|
39372
39372
|
warn(rule, enabled = true) {
|
|
39373
39373
|
rule.warn = enabled;
|
|
@@ -45243,7 +45243,7 @@ var require_schemas = __commonJSMin((exports) => {
|
|
|
45243
45243
|
var require_common = __commonJSMin((exports) => {
|
|
45244
45244
|
const { assert: Assert, AssertError } = require_lib$4();
|
|
45245
45245
|
const Pkg = (init_package(), __toCommonJS(package_exports).default);
|
|
45246
|
-
let Messages$
|
|
45246
|
+
let Messages$2;
|
|
45247
45247
|
let Schemas$1;
|
|
45248
45248
|
const internals$1 = { isoDate: /^(?:[-+]\d{2})?(?:\d{4}(?!\d{2}\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\1(?:[12]\d|0[1-9]|3[01]))?|W(?:[0-4]\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[1-6])))(?![T]$|[T][\d]+Z$)(?:[T\s](?:(?:(?:[01]\d|2[0-3])(?:(:?)[0-5]\d)?|24\:?00)(?:[.,]\d+(?!:))?)(?:\2[0-5]\d(?:[.,]\d+)?)?(?:[Z]|(?:[+-])(?:[01]\d|2[0-3])(?::?[0-5]\d)?)?)?)?$/ };
|
|
45249
45249
|
exports.version = Pkg.version;
|
|
@@ -45333,7 +45333,7 @@ var require_common = __commonJSMin((exports) => {
|
|
|
45333
45333
|
return Number.isSafeInteger(value) && value >= 0;
|
|
45334
45334
|
};
|
|
45335
45335
|
exports.preferences = function(target, source) {
|
|
45336
|
-
Messages$
|
|
45336
|
+
Messages$2 = Messages$2 || require_messages();
|
|
45337
45337
|
target = target || {};
|
|
45338
45338
|
source = source || {};
|
|
45339
45339
|
const merged = Object.assign({}, target, source);
|
|
@@ -45341,7 +45341,7 @@ var require_common = __commonJSMin((exports) => {
|
|
|
45341
45341
|
merged.errors = Object.assign({}, target.errors, source.errors);
|
|
45342
45342
|
merged.errors.wrap = Object.assign({}, target.errors.wrap, source.errors.wrap);
|
|
45343
45343
|
}
|
|
45344
|
-
if (source.messages) merged.messages = Messages$
|
|
45344
|
+
if (source.messages) merged.messages = Messages$2.compile(source.messages, target.messages);
|
|
45345
45345
|
delete merged[exports.symbols.prefs];
|
|
45346
45346
|
return merged;
|
|
45347
45347
|
};
|
|
@@ -45811,7 +45811,7 @@ var RootFactory = class RootFactory {
|
|
|
45811
45811
|
return instance;
|
|
45812
45812
|
}
|
|
45813
45813
|
};
|
|
45814
|
-
var import_messages = __toESM(require_messages());
|
|
45814
|
+
var import_messages$1 = __toESM(require_messages());
|
|
45815
45815
|
const knexMessages = {
|
|
45816
45816
|
"knex.unique": "The {{#label}} has already been taken",
|
|
45817
45817
|
"knex.exists": "The selected {{#label}} is invalid",
|
|
@@ -45859,7 +45859,7 @@ const resolveQueryBuilder = (connection, table$2) => {
|
|
|
45859
45859
|
query: conn.table(table$2)
|
|
45860
45860
|
};
|
|
45861
45861
|
};
|
|
45862
|
-
const getMergableMessages = (schema$2) => {
|
|
45862
|
+
const getMergableMessages$1 = (schema$2) => {
|
|
45863
45863
|
if ("_definition" in schema$2) {
|
|
45864
45864
|
const def = schema$2._definition;
|
|
45865
45865
|
if ("messages" in def && def.messages) if ("string" === typeof def.messages) return {};
|
|
@@ -45906,8 +45906,8 @@ function findKnexConnection() {
|
|
|
45906
45906
|
}
|
|
45907
45907
|
const knex = (schema$2, root$11, args$1) => {
|
|
45908
45908
|
const prototype = Object.getPrototypeOf(schema$2);
|
|
45909
|
-
const originalMessages = getMergableMessages(schema$2);
|
|
45910
|
-
const mergedMessages = import_messages.merge(originalMessages, knexMessages);
|
|
45909
|
+
const originalMessages = getMergableMessages$1(schema$2);
|
|
45910
|
+
const mergedMessages = import_messages$1.merge(originalMessages, knexMessages);
|
|
45911
45911
|
prototype._definition.messages = mergedMessages;
|
|
45912
45912
|
prototype._definition.flags.knexConnection = {
|
|
45913
45913
|
default: void 0,
|
|
@@ -46051,6 +46051,43 @@ const knex = (schema$2, root$11, args$1) => {
|
|
|
46051
46051
|
};
|
|
46052
46052
|
return RootFactory.generate(root$11, schema$2, args$1);
|
|
46053
46053
|
};
|
|
46054
|
+
var import_messages = __toESM(require_messages());
|
|
46055
|
+
const fqdnMessages = { "string.fqdn": "{{#label}} must be a valid fully qualified domain name" };
|
|
46056
|
+
const getMergableMessages = (schema$2) => {
|
|
46057
|
+
if ("_definition" in schema$2) {
|
|
46058
|
+
const def = schema$2._definition;
|
|
46059
|
+
if ("messages" in def && def.messages) if ("string" === typeof def.messages) return {};
|
|
46060
|
+
else return def.messages;
|
|
46061
|
+
}
|
|
46062
|
+
return {};
|
|
46063
|
+
};
|
|
46064
|
+
const fqdn = (schema$2, root$11, args$1) => {
|
|
46065
|
+
if (schema$2.type !== "string") return schema$2;
|
|
46066
|
+
const prototype = Object.getPrototypeOf(schema$2);
|
|
46067
|
+
const originalMessages = getMergableMessages(schema$2);
|
|
46068
|
+
const mergedMessages = import_messages.merge(originalMessages, fqdnMessages);
|
|
46069
|
+
prototype._definition.messages = mergedMessages;
|
|
46070
|
+
prototype._definition.rules.fqdn = {
|
|
46071
|
+
method() {
|
|
46072
|
+
return this.addRule("fqdn");
|
|
46073
|
+
},
|
|
46074
|
+
validate(value, helpers$8) {
|
|
46075
|
+
if ("string" !== typeof value || value.trim().length === 0) return void 0;
|
|
46076
|
+
if (value.includes("..")) return helpers$8.error("string.fqdn");
|
|
46077
|
+
const labels = value.split(".");
|
|
46078
|
+
for (const label of labels) {
|
|
46079
|
+
if (label.length === 0 || label.length > 63) return helpers$8.error("string.fqdn");
|
|
46080
|
+
if (label.startsWith("-") || label.endsWith("-")) return helpers$8.error("string.fqdn");
|
|
46081
|
+
if (!/^[a-zA-Z0-9-]+$/.test(label)) return helpers$8.error("string.fqdn");
|
|
46082
|
+
}
|
|
46083
|
+
return value;
|
|
46084
|
+
}
|
|
46085
|
+
};
|
|
46086
|
+
if (!prototype.fqdn) prototype.fqdn = function() {
|
|
46087
|
+
return this.$_addRule({ name: "fqdn" });
|
|
46088
|
+
};
|
|
46089
|
+
return RootFactory.generate(root$11, schema$2, args$1);
|
|
46090
|
+
};
|
|
46054
46091
|
var De = (t$7) => {
|
|
46055
46092
|
throw TypeError(t$7);
|
|
46056
46093
|
};
|
|
@@ -134813,6 +134850,13 @@ const phone = function(joi) {
|
|
|
134813
134850
|
type: "phone",
|
|
134814
134851
|
base: joi.any(),
|
|
134815
134852
|
validate(value, { error, schema: schema$2, prefs, state }) {
|
|
134853
|
+
const isEmpty$13 = value === null || value === void 0;
|
|
134854
|
+
const isRequired = schema$2._flags.presence === "required";
|
|
134855
|
+
if (isEmpty$13 && !isRequired) return { value: null };
|
|
134856
|
+
if (isEmpty$13 && isRequired) return {
|
|
134857
|
+
value,
|
|
134858
|
+
errors: [error("any.required", { label: schema$2._flags.label })]
|
|
134859
|
+
};
|
|
134816
134860
|
const arg = schema$2.$_getFlag("country");
|
|
134817
134861
|
const country = joi.isRef(arg) ? arg.resolve(value, state, prefs) : arg;
|
|
134818
134862
|
const pObj = getPhoneObject(value, country);
|
|
@@ -135521,6 +135565,13 @@ const bigint = function(joi) {
|
|
|
135521
135565
|
compare: {
|
|
135522
135566
|
method: false,
|
|
135523
135567
|
validate(value, helpers$8, { limit }, { name: name$2, operator: operator$1 }) {
|
|
135568
|
+
const isEmpty$13 = value === null || value === void 0;
|
|
135569
|
+
const isRequired = helpers$8.schema._flags.presence === "required";
|
|
135570
|
+
if (isEmpty$13 && !isRequired) return null;
|
|
135571
|
+
if (isEmpty$13 && isRequired) return {
|
|
135572
|
+
value,
|
|
135573
|
+
errors: [helpers$8.error("any.required", { label: helpers$8.schema._flags.label })]
|
|
135574
|
+
};
|
|
135524
135575
|
const big = big_default(value.toString());
|
|
135525
135576
|
const threshold = big_default(limit.toString());
|
|
135526
135577
|
const valid$2 = compare$13(big, threshold, operator$1);
|
|
@@ -140140,6 +140191,13 @@ const toDateTime = (value, format) => {
|
|
|
140140
140191
|
return false;
|
|
140141
140192
|
};
|
|
140142
140193
|
const coerce$2 = (value, helpers$8) => {
|
|
140194
|
+
const isEmpty$13 = value === null || value === void 0;
|
|
140195
|
+
const isRequired = helpers$8.schema._flags.presence === "required";
|
|
140196
|
+
if (isEmpty$13 && !isRequired) return { value: null };
|
|
140197
|
+
if (isEmpty$13 && isRequired) return {
|
|
140198
|
+
value,
|
|
140199
|
+
errors: [helpers$8.error("any.required", { label: helpers$8.schema._flags.label })]
|
|
140200
|
+
};
|
|
140143
140201
|
const converted = toDateTime(value);
|
|
140144
140202
|
if (converted) {
|
|
140145
140203
|
const { schema: schema$2, prefs } = helpers$8;
|
|
@@ -140544,7 +140602,8 @@ const knownMessages = {
|
|
|
140544
140602
|
...messages$1,
|
|
140545
140603
|
...messages$2,
|
|
140546
140604
|
...messages,
|
|
140547
|
-
...knexMessages
|
|
140605
|
+
...knexMessages,
|
|
140606
|
+
...fqdnMessages
|
|
140548
140607
|
};
|
|
140549
140608
|
countries.forEach((name$2, iso) => {
|
|
140550
140609
|
knownMessages[`country.${iso}`] = name$2;
|
|
@@ -140735,6 +140794,7 @@ const i18n = (toPatch) => {
|
|
|
140735
140794
|
"string.uriCustomScheme": $t("string.uriCustomScheme"),
|
|
140736
140795
|
"string.uriRelativeOnly": $t("string.uriRelativeOnly"),
|
|
140737
140796
|
"string.uppercase": $t("string.uppercase"),
|
|
140797
|
+
...fqdnMessages,
|
|
140738
140798
|
...knexTranslations
|
|
140739
140799
|
});
|
|
140740
140800
|
case "symbol": return applyMessagesToSchema(schema$2, {
|
|
@@ -143080,7 +143140,7 @@ const encode = (schema$2, options = {}) => {
|
|
|
143080
143140
|
});
|
|
143081
143141
|
}
|
|
143082
143142
|
const json$1 = JSON.stringify({
|
|
143083
|
-
version: "0.1.0-master-
|
|
143143
|
+
version: "0.1.0-master-06559f66",
|
|
143084
143144
|
schema: description$2
|
|
143085
143145
|
}, (key, value) => {
|
|
143086
143146
|
if (typeof value === "bigint") return value.toString();
|
|
@@ -143128,14 +143188,14 @@ const decode = (base64, options = {}) => {
|
|
|
143128
143188
|
});
|
|
143129
143189
|
if (!isPlainObject(description$2) || !("version" in description$2) || !("schema" in description$2) || typeof description$2.version !== "string" || !isPlainObject(description$2.schema)) throw new TypeError("Not a valid encoded schema");
|
|
143130
143190
|
const { version: schemaVersion, schema: schema$2 } = description$2;
|
|
143131
|
-
if (import_semver.valid("0.1.0-master-
|
|
143191
|
+
if (import_semver.valid("0.1.0-master-06559f66")) {
|
|
143132
143192
|
if (!import_semver.valid(import_semver.coerce(schemaVersion))) throw new TypeError(`Invalid schema version: ${schemaVersion}`);
|
|
143133
|
-
if (import_semver.gt(import_semver.coerce(schemaVersion), "0.1.0-master-
|
|
143193
|
+
if (import_semver.gt(import_semver.coerce(schemaVersion), "0.1.0-master-06559f66")) throw new TypeError(`Schema version ${schemaVersion} is not compatible with current version 0.1.0-master-06559f66`);
|
|
143134
143194
|
}
|
|
143135
143195
|
return validator.build(schema$2);
|
|
143136
143196
|
};
|
|
143137
143197
|
const Joi = RootFactory.create({
|
|
143138
|
-
schemaTypeModifiers: [knex],
|
|
143198
|
+
schemaTypeModifiers: [knex, fqdn],
|
|
143139
143199
|
shortcutsModifiers: []
|
|
143140
143200
|
});
|
|
143141
143201
|
const validator = patch(Joi.extend(bigint).extend(datetime).extend(phone));
|
|
@@ -144584,7 +144644,7 @@ init_esm();
|
|
|
144584
144644
|
var import_lib = __toESM(require_lib$3());
|
|
144585
144645
|
var import_lib$1 = __toESM(require_lib$2());
|
|
144586
144646
|
var import_lib$2 = __toESM(require_lib());
|
|
144587
|
-
const version = "0.1.0-master-
|
|
144647
|
+
const version = "0.1.0-master-06559f66";
|
|
144588
144648
|
var ValidationError = import_lib$2.ValidationError;
|
|
144589
144649
|
var location = import_lib$1.location;
|
|
144590
144650
|
export { ValidationError, esm_exports as address, decode, encode, import_lib as formula, location, tlds, validator, version };
|