@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.mjs
CHANGED
|
@@ -134850,6 +134850,13 @@ const phone = function(joi) {
|
|
|
134850
134850
|
type: "phone",
|
|
134851
134851
|
base: joi.any(),
|
|
134852
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
|
+
};
|
|
134853
134860
|
const arg = schema$2.$_getFlag("country");
|
|
134854
134861
|
const country = joi.isRef(arg) ? arg.resolve(value, state, prefs) : arg;
|
|
134855
134862
|
const pObj = getPhoneObject(value, country);
|
|
@@ -135558,6 +135565,13 @@ const bigint = function(joi) {
|
|
|
135558
135565
|
compare: {
|
|
135559
135566
|
method: false,
|
|
135560
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
|
+
};
|
|
135561
135575
|
const big = big_default(value.toString());
|
|
135562
135576
|
const threshold = big_default(limit.toString());
|
|
135563
135577
|
const valid$2 = compare$13(big, threshold, operator$1);
|
|
@@ -140177,6 +140191,13 @@ const toDateTime = (value, format) => {
|
|
|
140177
140191
|
return false;
|
|
140178
140192
|
};
|
|
140179
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
|
+
};
|
|
140180
140201
|
const converted = toDateTime(value);
|
|
140181
140202
|
if (converted) {
|
|
140182
140203
|
const { schema: schema$2, prefs } = helpers$8;
|
|
@@ -143119,7 +143140,7 @@ const encode = (schema$2, options = {}) => {
|
|
|
143119
143140
|
});
|
|
143120
143141
|
}
|
|
143121
143142
|
const json$1 = JSON.stringify({
|
|
143122
|
-
version: "0.1.0-master-
|
|
143143
|
+
version: "0.1.0-master-06559f66",
|
|
143123
143144
|
schema: description$2
|
|
143124
143145
|
}, (key, value) => {
|
|
143125
143146
|
if (typeof value === "bigint") return value.toString();
|
|
@@ -143167,9 +143188,9 @@ const decode = (base64, options = {}) => {
|
|
|
143167
143188
|
});
|
|
143168
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");
|
|
143169
143190
|
const { version: schemaVersion, schema: schema$2 } = description$2;
|
|
143170
|
-
if (import_semver.valid("0.1.0-master-
|
|
143191
|
+
if (import_semver.valid("0.1.0-master-06559f66")) {
|
|
143171
143192
|
if (!import_semver.valid(import_semver.coerce(schemaVersion))) throw new TypeError(`Invalid schema version: ${schemaVersion}`);
|
|
143172
|
-
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`);
|
|
143173
143194
|
}
|
|
143174
143195
|
return validator.build(schema$2);
|
|
143175
143196
|
};
|
|
@@ -144623,7 +144644,7 @@ init_esm();
|
|
|
144623
144644
|
var import_lib = __toESM(require_lib$3());
|
|
144624
144645
|
var import_lib$1 = __toESM(require_lib$2());
|
|
144625
144646
|
var import_lib$2 = __toESM(require_lib());
|
|
144626
|
-
const version = "0.1.0-master-
|
|
144647
|
+
const version = "0.1.0-master-06559f66";
|
|
144627
144648
|
var ValidationError = import_lib$2.ValidationError;
|
|
144628
144649
|
var location = import_lib$1.location;
|
|
144629
144650
|
export { ValidationError, esm_exports as address, decode, encode, import_lib as formula, location, tlds, validator, version };
|