@nhtio/validation 0.1.0-master-1d06eb16 → 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/index.cjs +25 -4
- package/index.cjs.map +1 -1
- package/index.mjs +25 -4
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/private/schemas/datetime.d.ts +1 -1
package/index.cjs
CHANGED
|
@@ -134846,6 +134846,13 @@ const phone = function(joi) {
|
|
|
134846
134846
|
type: "phone",
|
|
134847
134847
|
base: joi.any(),
|
|
134848
134848
|
validate(value, { error, schema: schema$2, prefs, state }) {
|
|
134849
|
+
const isEmpty$13 = value === null || value === void 0;
|
|
134850
|
+
const isRequired = schema$2._flags.presence === "required";
|
|
134851
|
+
if (isEmpty$13 && !isRequired) return { value: null };
|
|
134852
|
+
if (isEmpty$13 && isRequired) return {
|
|
134853
|
+
value,
|
|
134854
|
+
errors: [error("any.required", { label: schema$2._flags.label })]
|
|
134855
|
+
};
|
|
134849
134856
|
const arg = schema$2.$_getFlag("country");
|
|
134850
134857
|
const country = joi.isRef(arg) ? arg.resolve(value, state, prefs) : arg;
|
|
134851
134858
|
const pObj = getPhoneObject(value, country);
|
|
@@ -135554,6 +135561,13 @@ const bigint = function(joi) {
|
|
|
135554
135561
|
compare: {
|
|
135555
135562
|
method: false,
|
|
135556
135563
|
validate(value, helpers$8, { limit }, { name: name$2, operator: operator$1 }) {
|
|
135564
|
+
const isEmpty$13 = value === null || value === void 0;
|
|
135565
|
+
const isRequired = helpers$8.schema._flags.presence === "required";
|
|
135566
|
+
if (isEmpty$13 && !isRequired) return null;
|
|
135567
|
+
if (isEmpty$13 && isRequired) return {
|
|
135568
|
+
value,
|
|
135569
|
+
errors: [helpers$8.error("any.required", { label: helpers$8.schema._flags.label })]
|
|
135570
|
+
};
|
|
135557
135571
|
const big = big_default(value.toString());
|
|
135558
135572
|
const threshold = big_default(limit.toString());
|
|
135559
135573
|
const valid$2 = compare$13(big, threshold, operator$1);
|
|
@@ -140173,6 +140187,13 @@ const toDateTime = (value, format) => {
|
|
|
140173
140187
|
return false;
|
|
140174
140188
|
};
|
|
140175
140189
|
const coerce$2 = (value, helpers$8) => {
|
|
140190
|
+
const isEmpty$13 = value === null || value === void 0;
|
|
140191
|
+
const isRequired = helpers$8.schema._flags.presence === "required";
|
|
140192
|
+
if (isEmpty$13 && !isRequired) return { value: null };
|
|
140193
|
+
if (isEmpty$13 && isRequired) return {
|
|
140194
|
+
value,
|
|
140195
|
+
errors: [helpers$8.error("any.required", { label: helpers$8.schema._flags.label })]
|
|
140196
|
+
};
|
|
140176
140197
|
const converted = toDateTime(value);
|
|
140177
140198
|
if (converted) {
|
|
140178
140199
|
const { schema: schema$2, prefs } = helpers$8;
|
|
@@ -143115,7 +143136,7 @@ const encode = (schema$2, options = {}) => {
|
|
|
143115
143136
|
});
|
|
143116
143137
|
}
|
|
143117
143138
|
const json$1 = JSON.stringify({
|
|
143118
|
-
version: "0.1.0-master-
|
|
143139
|
+
version: "0.1.0-master-06559f66",
|
|
143119
143140
|
schema: description$2
|
|
143120
143141
|
}, (key, value) => {
|
|
143121
143142
|
if (typeof value === "bigint") return value.toString();
|
|
@@ -143163,9 +143184,9 @@ const decode = (base64, options = {}) => {
|
|
|
143163
143184
|
});
|
|
143164
143185
|
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");
|
|
143165
143186
|
const { version: schemaVersion, schema: schema$2 } = description$2;
|
|
143166
|
-
if (import_semver.valid("0.1.0-master-
|
|
143187
|
+
if (import_semver.valid("0.1.0-master-06559f66")) {
|
|
143167
143188
|
if (!import_semver.valid(import_semver.coerce(schemaVersion))) throw new TypeError(`Invalid schema version: ${schemaVersion}`);
|
|
143168
|
-
if (import_semver.gt(import_semver.coerce(schemaVersion), "0.1.0-master-
|
|
143189
|
+
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`);
|
|
143169
143190
|
}
|
|
143170
143191
|
return validator.build(schema$2);
|
|
143171
143192
|
};
|
|
@@ -144619,7 +144640,7 @@ init_esm();
|
|
|
144619
144640
|
var import_lib = __toESM(require_lib$3());
|
|
144620
144641
|
var import_lib$1 = __toESM(require_lib$2());
|
|
144621
144642
|
var import_lib$2 = __toESM(require_lib());
|
|
144622
|
-
const version = "0.1.0-master-
|
|
144643
|
+
const version = "0.1.0-master-06559f66";
|
|
144623
144644
|
Object.defineProperty(exports, "ValidationError", {
|
|
144624
144645
|
enumerable: true,
|
|
144625
144646
|
get: function() {
|