Socket
Socket
Sign inDemoInstall

node-input-validator

Package Overview
Dependencies
19
Maintainers
2
Versions
101
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0-beta.5 to 5.0.0-beta.6

cjs/validator-abs.backup.js

9

changelogs/V5.md
# Version 5 Changelog
## [UNRELEASED]
## [unreleased]
- feat: filter inputs
- feat: get appropriate inputs
- fix: rule in args missing
- change: config `wildcardIterations` not applicable now
## [5.0.0-beta.6]
- fix: nested validations
- fix: get rid of --experimental-specifier-resolution
- fix: sometimes and nullable rules
## [5.0.0-beta.5]

@@ -8,0 +15,0 @@ - fix: nested inputs validation

4

cjs/config.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addImplicitRule = exports.modify = exports.get = exports.set = void 0;
const contracts_1 = require("./contracts");
const contracts_js_1 = require("./contracts.js");
let config = {
wildcardIterations: 1000,
wildcardSeperator: '.',
lang: contracts_1.Langs.en_US,
lang: contracts_js_1.Langs.en_US,
implicitRules: [

@@ -10,0 +10,0 @@ "required",

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DateFnsAdapter = void 0;
const contracts_1 = require("./contracts");
class DateFnsAdapter extends contracts_1.DateAdapter {
const contracts_js_1 = require("./contracts.js");
class DateFnsAdapter extends contracts_js_1.DateAdapter {
constructor(dateLib) {

@@ -7,0 +7,0 @@ super(dateLib);

@@ -14,9 +14,9 @@ "use strict";

exports.dateAdapter = exports.DateAdapter = void 0;
const contracts_1 = require("./contracts");
Object.defineProperty(exports, "DateAdapter", { enumerable: true, get: function () { return contracts_1.DateAdapter; } });
const config_1 = require("../config");
__exportStar(require("./date-fns.adapter"), exports);
__exportStar(require("./moment.adapter"), exports);
const contracts_js_1 = require("./contracts.js");
Object.defineProperty(exports, "DateAdapter", { enumerable: true, get: function () { return contracts_js_1.DateAdapter; } });
const config_js_1 = require("../config.js");
__exportStar(require("./date-fns.adapter.js"), exports);
__exportStar(require("./moment.adapter.js"), exports);
function dateAdapter() {
const adapterInstance = config_1.get('dateAdapter');
const adapterInstance = config_js_1.get('dateAdapter');
if (!adapterInstance) {

@@ -23,0 +23,0 @@ throw new Error('Please set date adapter to use date rules.');

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MomentAdapter = void 0;
const contracts_1 = require("./contracts");
class MomentAdapter extends contracts_1.DateAdapter {
const contracts_js_1 = require("./contracts.js");
class MomentAdapter extends contracts_js_1.DateAdapter {
constructor(dateLib) {

@@ -7,0 +7,0 @@ super(dateLib);

@@ -26,12 +26,12 @@ "use strict";

exports.bailable = exports.koa = exports.extend = exports.addImplicitRule = exports.lang = exports.useDateAdapter = exports.configure = exports.Rules = exports.Validator = void 0;
__exportStar(require("./contracts"), exports);
exports.Messages = __importStar(require("./messages"));
const Rules = __importStar(require("./rules"));
__exportStar(require("./contracts.js"), exports);
exports.Messages = __importStar(require("./messages/index.js"));
const Rules = __importStar(require("./rules/index.js"));
exports.Rules = Rules;
const validator_1 = require("./validator");
Object.defineProperty(exports, "Validator", { enumerable: true, get: function () { return validator_1.Validator; } });
var date_1 = require("./date");
Object.defineProperty(exports, "MomentAdapter", { enumerable: true, get: function () { return date_1.MomentAdapter; } });
Object.defineProperty(exports, "DateFnsAdapter", { enumerable: true, get: function () { return date_1.DateFnsAdapter; } });
const config = __importStar(require("./config"));
const validator_js_1 = require("./validator.js");
Object.defineProperty(exports, "Validator", { enumerable: true, get: function () { return validator_js_1.Validator; } });
var index_js_1 = require("./date/index.js");
Object.defineProperty(exports, "MomentAdapter", { enumerable: true, get: function () { return index_js_1.MomentAdapter; } });
Object.defineProperty(exports, "DateFnsAdapter", { enumerable: true, get: function () { return index_js_1.DateFnsAdapter; } });
const config = __importStar(require("./config.js"));
function configure(customConf) {

@@ -71,3 +71,3 @@ config.set(customConf);

ctx.validate = async function validate(rulesArray, inputs, useMessages) {
const v = new validator_1.Validator(inputs || Object.assign(Object.assign({}, this.request.body), this.request.files), rulesArray || {}, useMessages || {});
const v = new validator_js_1.Validator(inputs || Object.assign(Object.assign({}, this.request.body), this.request.files), rulesArray || {}, useMessages || {});
if (!(await v.validate())) {

@@ -78,3 +78,3 @@ this.throw(422, this.validationErrors(v.errors));

};
ctx.validator = (inputs, rulesArray, useMessages) => new validator_1.Validator(inputs, rulesArray, useMessages);
ctx.validator = (inputs, rulesArray, useMessages) => new validator_js_1.Validator(inputs, rulesArray, useMessages);
try {

@@ -100,5 +100,5 @@ await next();

function bailable(sure) {
validator_1.Validator.bailable(sure);
validator_js_1.Validator.bailable(sure);
}
exports.bailable = bailable;
//# sourceMappingURL=index.js.map

@@ -25,4 +25,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Messages = __importStar(require("./messages"));
__exportStar(require("./provider"), exports);
exports.Messages = __importStar(require("./messages.js"));
__exportStar(require("./provider.js"), exports);
//# sourceMappingURL=index.js.map

@@ -23,7 +23,7 @@ "use strict";

exports.en_US = void 0;
const contracts_1 = require("../contracts");
const en_US = __importStar(require("./en-US.messages"));
const contracts_js_1 = require("../contracts.js");
const en_US = __importStar(require("./en-US.messages.js"));
exports.en_US = en_US;
const provider_1 = require("./provider");
provider_1.extend(en_US.messages, contracts_1.Langs.en_US);
const provider_js_1 = require("./provider.js");
provider_js_1.extend(en_US.messages, contracts_js_1.Langs.en_US);
//# sourceMappingURL=messages.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addNiceNames = exports.addCustomMessages = exports.extend = exports.messagesRefByLang = exports.DEFAULT_LANG = void 0;
const obj_util_1 = require("../utils/obj.util");
const contracts_1 = require("../contracts");
exports.DEFAULT_LANG = contracts_1.Langs.en_US;
const obj_util_js_1 = require("../utils/obj.util.js");
const contracts_js_1 = require("../contracts.js");
exports.DEFAULT_LANG = contracts_js_1.Langs.en_US;
const MessagesRef = {};
function messagesRefByLang(lang) {
let messages = obj_util_1.getKeyValue(lang.toString())(MessagesRef);
let messages = obj_util_js_1.getKeyValue(lang.toString())(MessagesRef);
if (typeof messages === "undefined") {
// @ts-ignore
MessagesRef[lang] = { messages: {} };
messages = obj_util_1.getKeyValue(lang.toString())(MessagesRef);
messages = obj_util_js_1.getKeyValue(lang.toString())(MessagesRef);
}

@@ -19,3 +19,3 @@ return messages;

;
function extend(newMessages, lang = contracts_1.Langs.en_US) {
function extend(newMessages, lang = contracts_js_1.Langs.en_US) {
const messages = messagesRefByLang(lang);

@@ -25,3 +25,3 @@ Object.assign(messages, newMessages);

exports.extend = extend;
function addCustomMessages(customMessages, lang = contracts_1.Langs.en_US) {
function addCustomMessages(customMessages, lang = contracts_js_1.Langs.en_US) {
const messages = messagesRefByLang(lang);

@@ -34,3 +34,3 @@ if (!messages.$custom) {

exports.addCustomMessages = addCustomMessages;
function addNiceNames(attributesNiceNames, lang = contracts_1.Langs.en_US) {
function addNiceNames(attributesNiceNames, lang = contracts_js_1.Langs.en_US) {
const messages = messagesRefByLang(lang);

@@ -37,0 +37,0 @@ if (!messages.$niceNames) {

@@ -30,3 +30,3 @@ "use strict";

v.createAttributeError({
ruleName: 'any',
ruleName: 'all',
attrName: '*',

@@ -33,0 +33,0 @@ attrValue: values,

@@ -6,3 +6,3 @@ "use strict";

return {
name: 'all',
name: 'any',
handler: (_, v) => {

@@ -9,0 +9,0 @@ // @ts-ignore

@@ -13,4 +13,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./all"), exports);
__exportStar(require("./any"), exports);
__exportStar(require("./all.js"), exports);
__exportStar(require("./any.js"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.acceptedNotIf = exports.acceptedIf = exports.accepted = void 0;
const ops_util_1 = require("../utils/ops.util");
const ops_util_js_1 = require("../utils/ops.util.js");
/**

@@ -66,3 +66,3 @@ * The field under validation must be yes, on, 1, or true.

const actualValue = v.attributeValue(attrName);
if (ops_util_1.reallyEmpty(actualValue)
if (ops_util_js_1.reallyEmpty(actualValue)
|| String(requiredAttrVal) !== String(actualValue)) {

@@ -111,3 +111,3 @@ required = false;

const actualValue = v.attributeValue(attrName);
if (ops_util_1.reallyEmpty(actualValue)
if (ops_util_js_1.reallyEmpty(actualValue)
|| String(requiredAttrVal) === String(actualValue)) {

@@ -114,0 +114,0 @@ required = false;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.between = void 0;
const number_util_1 = require("../utils/number.util");
const number_util_js_1 = require("../utils/number.util.js");
/**

@@ -15,3 +15,3 @@ * The field under validation must be between min and max seed.

}
if (!number_util_1.isNumeric(args[0]) || !number_util_1.isNumeric(args[0])) {
if (!number_util_js_1.isNumeric(args[0]) || !number_util_js_1.isNumeric(args[0])) {
throw new TypeError('Seeds must be number.');

@@ -32,3 +32,3 @@ }

const v = String(value[i]);
if (!number_util_1.isNumeric(v)) {
if (!number_util_js_1.isNumeric(v)) {
return false;

@@ -45,3 +45,3 @@ }

const v = String(value);
if (!number_util_1.isNumeric(v)) {
if (!number_util_js_1.isNumeric(v)) {
return false;

@@ -48,0 +48,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.creditCard = void 0;
const borrowed_1 = require("../utils/borrowed");
const borrowed_js_1 = require("../utils/borrowed.js");
function creditCard() {

@@ -12,3 +12,3 @@ return {

}
return borrowed_1.isCreditCard(value);
return borrowed_js_1.isCreditCard(value);
},

@@ -15,0 +15,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.date = exports.datetime = exports.dateISO = exports.dateFormat = exports.dateBeforeToday = exports.before = exports.dateBefore = exports.dateAfterToday = exports.after = exports.dateAfter = void 0;
const date_1 = require("../date");
const index_js_1 = require("../date/index.js");
function dateAfter(args) {

@@ -9,3 +9,3 @@ if (args.length !== 2) {

}
const adapter = date_1.dateAdapter();
const adapter = index_js_1.dateAdapter();
const [format, dateToCompare] = args;

@@ -27,3 +27,3 @@ if (typeof format !== 'string') {

}
const adapter = date_1.dateAdapter();
const adapter = index_js_1.dateAdapter();
const [format, dateToCompare] = args;

@@ -45,3 +45,3 @@ if (typeof format !== 'string') {

}
const adapter = date_1.dateAdapter();
const adapter = index_js_1.dateAdapter();
const [format] = args;

@@ -60,3 +60,3 @@ return {

}
const adapter = date_1.dateAdapter();
const adapter = index_js_1.dateAdapter();
const [format, dateToCompare] = args;

@@ -78,3 +78,3 @@ if (typeof format !== 'string') {

}
const adapter = date_1.dateAdapter();
const adapter = index_js_1.dateAdapter();
const [format, dateToCompare] = args;

@@ -96,3 +96,3 @@ if (typeof format !== 'string') {

}
const adapter = date_1.dateAdapter();
const adapter = index_js_1.dateAdapter();
const [format] = args;

@@ -112,3 +112,3 @@ return {

const [format] = args;
const adapter = date_1.dateAdapter();
const adapter = index_js_1.dateAdapter();
return {

@@ -123,3 +123,3 @@ name: "dateFormat",

function dateISO() {
const adapter = date_1.dateAdapter();
const adapter = index_js_1.dateAdapter();
return {

@@ -135,3 +135,3 @@ name: "dateISO",

function datetime() {
const adapter = date_1.dateAdapter();
const adapter = index_js_1.dateAdapter();
return {

@@ -146,3 +146,3 @@ name: 'datetime',

function date(args = []) {
const adapter = date_1.dateAdapter();
const adapter = index_js_1.dateAdapter();
const [format = adapter.FORMAT_DATE] = args;

@@ -149,0 +149,0 @@ return {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.digitsBetween = exports.digits = void 0;
const number_util_1 = require("../utils/number.util");
const number_util_js_1 = require("../utils/number.util.js");
function digits(args = []) {

@@ -18,3 +18,3 @@ if (args.length !== 1) {

const v = String(value);
if (number_util_1.isInt(v, true)
if (number_util_js_1.isInt(v, true)
&& v.length === len) {

@@ -46,3 +46,3 @@ return true;

const len = v.length;
if (number_util_1.isInt(v, true)
if (number_util_js_1.isInt(v, true)
&& len >= minInt

@@ -49,0 +49,0 @@ && len <= maxInt) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.domain = void 0;
const borrowed_1 = require("../utils/borrowed");
const borrowed_js_1 = require("../utils/borrowed.js");
function domain() {

@@ -12,3 +12,3 @@ return {

}
return borrowed_1.isDomain(value);
return borrowed_js_1.isDomain(value);
},

@@ -15,0 +15,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.email = void 0;
const borrowed_1 = require("../utils/borrowed");
const borrowed_js_1 = require("../utils/borrowed.js");
function email() {

@@ -12,3 +12,3 @@ return {

}
return borrowed_1.isEmail(value);
return borrowed_js_1.isEmail(value);
},

@@ -15,0 +15,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hexColor = exports.hex = void 0;
const str_util_1 = require("../utils/str.util");
const str_util_js_1 = require("../utils/str.util.js");
const hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;

@@ -14,3 +14,3 @@ const hexadecimal = /^(0x|0h)?[0-9A-F]+$/i;

}
return str_util_1.isHexadecimal(value);
return str_util_js_1.isHexadecimal(value);
},

@@ -17,0 +17,0 @@ };

@@ -5,3 +5,3 @@ "use strict";

function _in(args) {
if (!args.length) {
if (!args || !args.length) {
throw new Error('Invalid number of arguments.');

@@ -8,0 +8,0 @@ }

@@ -13,42 +13,42 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./accepted.rule"), exports);
__exportStar(require("./alpha.rule"), exports);
__exportStar(require("./array.rule"), exports);
__exportStar(require("./between.rule"), exports);
__exportStar(require("./boolean.rule"), exports);
__exportStar(require("./confirmed.rule"), exports);
__exportStar(require("./contains.rule"), exports);
__exportStar(require("./creditCard.rule"), exports);
__exportStar(require("./date.rule"), exports);
__exportStar(require("./dateiso.rule"), exports);
__exportStar(require("./different.rule"), exports);
__exportStar(require("./digits.rule"), exports);
__exportStar(require("./domain.rule"), exports);
__exportStar(require("./email.rule"), exports);
__exportStar(require("./encoding.rule"), exports);
__exportStar(require("./equals.rule"), exports);
__exportStar(require("./gt.rule"), exports);
__exportStar(require("./hash.rule"), exports);
__exportStar(require("./hex.rule"), exports);
var in_rule_1 = require("./in.rule");
Object.defineProperty(exports, "in", { enumerable: true, get: function () { return in_rule_1._in; } });
Object.defineProperty(exports, "notIn", { enumerable: true, get: function () { return in_rule_1.notIn; } });
__exportStar(require("./ip.rule"), exports);
__exportStar(require("./latLong.rule"), exports);
__exportStar(require("./length.rule"), exports);
__exportStar(require("./lt.rule"), exports);
__exportStar(require("./macAddress.rule"), exports);
__exportStar(require("./mime.rule"), exports);
__exportStar(require("./mongoId.rule"), exports);
__exportStar(require("./number.rule"), exports);
__exportStar(require("./object.rule"), exports);
__exportStar(require("./phoneNumber.rule"), exports);
__exportStar(require("./regex.rule"), exports);
__exportStar(require("./required.rule"), exports);
__exportStar(require("./same.rule"), exports);
__exportStar(require("./size.rule"), exports);
__exportStar(require("./special.rule"), exports);
__exportStar(require("./string.rule"), exports);
__exportStar(require("./url.rule"), exports);
__exportStar(require("./validator.rule"), exports);
__exportStar(require("./accepted.rule.js"), exports);
__exportStar(require("./alpha.rule.js"), exports);
__exportStar(require("./array.rule.js"), exports);
__exportStar(require("./between.rule.js"), exports);
__exportStar(require("./boolean.rule.js"), exports);
__exportStar(require("./confirmed.rule.js"), exports);
__exportStar(require("./contains.rule.js"), exports);
__exportStar(require("./creditCard.rule.js"), exports);
__exportStar(require("./date.rule.js"), exports);
__exportStar(require("./dateiso.rule.js"), exports);
__exportStar(require("./different.rule.js"), exports);
__exportStar(require("./digits.rule.js"), exports);
__exportStar(require("./domain.rule.js"), exports);
__exportStar(require("./email.rule.js"), exports);
__exportStar(require("./encoding.rule.js"), exports);
__exportStar(require("./equals.rule.js"), exports);
__exportStar(require("./gt.rule.js"), exports);
__exportStar(require("./hash.rule.js"), exports);
__exportStar(require("./hex.rule.js"), exports);
var in_rule_js_1 = require("./in.rule.js");
Object.defineProperty(exports, "in", { enumerable: true, get: function () { return in_rule_js_1._in; } });
Object.defineProperty(exports, "notIn", { enumerable: true, get: function () { return in_rule_js_1.notIn; } });
__exportStar(require("./ip.rule.js"), exports);
__exportStar(require("./latLong.rule.js"), exports);
__exportStar(require("./length.rule.js"), exports);
__exportStar(require("./lt.rule.js"), exports);
__exportStar(require("./macAddress.rule.js"), exports);
__exportStar(require("./mime.rule.js"), exports);
__exportStar(require("./mongoId.rule.js"), exports);
__exportStar(require("./number.rule.js"), exports);
__exportStar(require("./object.rule.js"), exports);
__exportStar(require("./phoneNumber.rule.js"), exports);
__exportStar(require("./regex.rule.js"), exports);
__exportStar(require("./required.rule.js"), exports);
__exportStar(require("./same.rule.js"), exports);
__exportStar(require("./size.rule.js"), exports);
__exportStar(require("./special.rule.js"), exports);
__exportStar(require("./string.rule.js"), exports);
__exportStar(require("./url.rule.js"), exports);
__exportStar(require("./validator.rule.js"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ip = void 0;
const borrowed_1 = require("../utils/borrowed");
const borrowed_js_1 = require("../utils/borrowed.js");
function ip(args = []) {

@@ -12,3 +12,3 @@ return {

}
return borrowed_1.isIp(value, args[0] || '');
return borrowed_js_1.isIp(value, args[0] || '');
},

@@ -15,0 +15,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mongoId = void 0;
const str_util_1 = require("../utils/str.util");
const str_util_js_1 = require("../utils/str.util.js");
function mongoId() {

@@ -12,3 +12,3 @@ return {

}
return str_util_1.isHexadecimal(value) && value.length === 24;
return str_util_js_1.isHexadecimal(value) && value.length === 24;
},

@@ -15,0 +15,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.numeric = exports.decimal = exports.max = exports.min = exports.integer = void 0;
const number_util_1 = require("../utils/number.util");
const number_util_js_1 = require("../utils/number.util.js");
function integer(args = []) {

@@ -9,3 +9,3 @@ return {

handler: (value) => {
return number_util_1.isInt(value + "", args && args[0] === '0');
return number_util_js_1.isInt(value + "", args && args[0] === '0');
},

@@ -27,3 +27,3 @@ };

const v = String(value);
if (!number_util_1.isNumeric(v)
if (!number_util_js_1.isNumeric(v)
|| Number(v) < minNum) {

@@ -49,3 +49,3 @@ return false;

const v = String(value);
if (!number_util_1.isNumeric(v)
if (!number_util_js_1.isNumeric(v)
|| Number(v) > maxNum) {

@@ -66,3 +66,3 @@ return false;

}
return number_util_1.isDecimal(value);
return number_util_js_1.isDecimal(value);
},

@@ -76,3 +76,3 @@ };

handler: (value) => {
return number_util_1.isNumeric(value + "");
return number_util_js_1.isNumeric(value + "");
},

@@ -79,0 +79,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.requiredWithAll = exports.requiredWith = exports.requiredWithoutAll = exports.requiredWithout = exports.requiredIf = exports.required = void 0;
const ops_util_1 = require("../utils/ops.util");
const ops_util_js_1 = require("../utils/ops.util.js");
function required() {

@@ -9,3 +9,3 @@ return {

handler: (value) => {
return ops_util_1.reallyEmpty(value) === false;
return ops_util_js_1.reallyEmpty(value) === false;
},

@@ -31,3 +31,3 @@ };

const actualValue = v.attributeValue(attrName);
if (ops_util_1.reallyEmpty(actualValue)
if (ops_util_js_1.reallyEmpty(actualValue)
|| String(requiredAttrVal) !== String(actualValue)) {

@@ -38,3 +38,3 @@ required = false;

}
return (required && ops_util_1.reallyEmpty(value)) ? false : true;
return (required && ops_util_js_1.reallyEmpty(value)) ? false : true;
},

@@ -63,3 +63,3 @@ };

const actualValue = v.attributeValue(attrName);
if (ops_util_1.reallyEmpty(actualValue)) {
if (ops_util_js_1.reallyEmpty(actualValue)) {
required = true;

@@ -69,3 +69,3 @@ break;

}
return (required && ops_util_1.reallyEmpty(value)) ? false : true;
return (required && ops_util_js_1.reallyEmpty(value)) ? false : true;
},

@@ -95,3 +95,3 @@ };

const actualValue = v.attributeValue(attrName);
if (ops_util_1.reallyEmpty(actualValue)) {
if (ops_util_js_1.reallyEmpty(actualValue)) {
required = true;

@@ -103,3 +103,3 @@ }

}
return (required && ops_util_1.reallyEmpty(value)) ? false : true;
return (required && ops_util_js_1.reallyEmpty(value)) ? false : true;
},

@@ -128,3 +128,3 @@ };

const actualValue = v.attributeValue(attrName);
if (ops_util_1.reallyEmpty(actualValue)) {
if (ops_util_js_1.reallyEmpty(actualValue)) {
required = false;

@@ -134,3 +134,3 @@ break;

}
return (required && ops_util_1.reallyEmpty(value)) ? false : true;
return (required && ops_util_js_1.reallyEmpty(value)) ? false : true;
},

@@ -160,3 +160,3 @@ };

const actualValue = v.attributeValue(attrName);
if (ops_util_1.reallyEmpty(actualValue)) {
if (ops_util_js_1.reallyEmpty(actualValue)) {
required = false;

@@ -168,3 +168,3 @@ }

}
return (required && ops_util_1.reallyEmpty(value)) ? false : true;
return (required && ops_util_js_1.reallyEmpty(value)) ? false : true;
},

@@ -171,0 +171,0 @@ };

@@ -9,3 +9,3 @@ "use strict";

const util_1 = __importDefault(require("util"));
const str_util_1 = require("../utils/str.util");
const str_util_js_1 = require("../utils/str.util.js");
/**

@@ -44,5 +44,5 @@ * check if bytes are within given range

let size;
const maxBytes = str_util_1.sizeToBytes(args[0]);
const maxBytes = str_util_js_1.sizeToBytes(args[0]);
if (args.length >= 2) {
minBytes = str_util_1.sizeToBytes(args[1]);
minBytes = str_util_js_1.sizeToBytes(args[1]);
}

@@ -49,0 +49,0 @@ return {

@@ -8,2 +8,5 @@ "use strict";

handler: (value) => {
if (value != null) {
return -1;
}
return true;

@@ -17,3 +20,6 @@ },

name: "sometimes",
handler: (value) => {
handler: (value, v, name, { inputs }) => {
if (inputs[name] != undefined) {
return -1;
}
return true;

@@ -20,0 +26,0 @@ },

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.messageParser = void 0;
const str_util_1 = require("./str.util");
const str_util_js_1 = require("./str.util.js");
function messageParser(params) {

@@ -19,3 +19,3 @@ const { message, attrName, niceName, ruleArgs, ruleName, attrValue } = params;

if (!niceName && attributeName.indexOf(".") < 0) {
attributeName = str_util_1.camelCaseToSentance(str_util_1.snakeCaseToSentance(attrName));
attributeName = str_util_js_1.camelCaseToSentance(str_util_js_1.snakeCaseToSentance(attrName));
}

@@ -22,0 +22,0 @@ defaultMessage = defaultMessage.replace(":attr", attributeName);

@@ -23,3 +23,3 @@ "use strict";

exports.isObject = exports.getValuesByWildCardStringNotation = exports.isIterable = exports.getValueByStringNotation = exports.namedArgs = exports.getKeyValue = void 0;
const config = __importStar(require("../config"));
const config = __importStar(require("../config.js"));
function getKeyValue(key) {

@@ -26,0 +26,0 @@ return (obj) => obj[key];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fillMissingSpots = exports.mergeDeep = exports.reallyEmpty = void 0;
const obj_util_1 = require("./obj.util");
const obj_util_js_1 = require("./obj.util.js");
function reallyEmpty(value) {

@@ -14,5 +14,5 @@ const str = (value === undefined || value === null ? "" : value) + "";

const source = sources.shift();
if (obj_util_1.isObject(target) && obj_util_1.isObject(source)) {
if (obj_util_js_1.isObject(target) && obj_util_js_1.isObject(source)) {
for (const key in source) {
if (obj_util_1.isObject(source[key])) {
if (obj_util_js_1.isObject(source[key])) {
if (!target[key])

@@ -19,0 +19,0 @@ Object.assign(target, { [key]: {} });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseStringRule = exports.parseStringNotationRules = void 0;
const obj_util_1 = require("./obj.util");
const obj_util_js_1 = require("./obj.util.js");
/**

@@ -26,3 +26,3 @@ * parse rules those are in string notation

}
const ruleProvider = obj_util_1.getKeyValue(ruleName)(RulesProvider);
const ruleProvider = obj_util_js_1.getKeyValue(ruleName)(RulesProvider);
if (!ruleProvider) {

@@ -29,0 +29,0 @@ throw new Error(`Rule ${ruleName} does not exists.`);

@@ -23,8 +23,8 @@ "use strict";

exports.ValidatorAbstract = exports.registerPostRules = exports.registerRules = void 0;
const message_parser_util_1 = require("./utils/message-parser.util");
const ops_util_1 = require("./utils/ops.util");
const obj_util_1 = require("./utils/obj.util");
const rules_parser_util_1 = require("./utils/rules-parser.util");
const MessagesProvider = __importStar(require("./messages/provider"));
const config = __importStar(require("./config"));
const message_parser_util_js_1 = require("./utils/message-parser.util.js");
const ops_util_js_1 = require("./utils/ops.util.js");
const obj_util_js_1 = require("./utils/obj.util.js");
const rules_parser_util_js_1 = require("./utils/rules-parser.util.js");
const MessagesProvider = __importStar(require("./messages/provider.js"));
const config = __importStar(require("./config.js"));
let RulesProvider = {};

@@ -178,88 +178,43 @@ let PostRulesProvider = {};

parseRules() {
let attr;
for (attr of Object.keys(this.rules)) {
if (attr === '*') {
this.addPostRules(this.rules[attr]);
return;
const keys = Object.keys(this.rules);
const parsed = {};
for (const key of keys) {
if (key === '*') {
this.addPostRules(this.rules[key]);
continue;
}
if (attr.indexOf(".")) {
this.hasNestedRules = true;
let rules = this.rules[key];
if (Array.isArray(rules)) {
for (const index in rules) {
if (typeof rules[index] == 'string') {
rules[index] = rules_parser_util_js_1.parseStringRule(RulesProvider, rules[index]);
}
}
}
const attrRules = this.rules[attr];
if (typeof attrRules === 'string') {
this.parsedRulesCollection[attr] = rules_parser_util_1.parseStringNotationRules(RulesProvider, attrRules);
}
else {
attrRules.forEach((strRule, index) => {
if (typeof strRule === 'string') {
attrRules[index] = rules_parser_util_1.parseStringRule(RulesProvider, strRule);
}
});
// @ts-ignore
this.parsedRulesCollection[attr] = attrRules;
rules = rules_parser_util_js_1.parseStringNotationRules(RulesProvider, rules);
}
// sort rules as
this.parsedRulesCollection[attr].sort((obj) => {
rules.sort((obj) => {
return (this.implicitRules.indexOf(obj.name) >= 0) ? -1 : 1;
});
let kobj = parsed;
let path = '';
key.split('.').forEach((k, i) => {
path += k;
if (!kobj[k]) {
kobj[k] = {
rules: this.rules[path] ? rules : [],
child: {},
};
}
kobj = kobj[k].child;
path += '.';
});
}
this.parsedRulesCollection = parsed;
}
fillMissingAttributes(key) {
const data = {};
const [frontKey] = key.split('.');
data[frontKey] = this.inputs[frontKey];
ops_util_1.fillMissingSpots(data, key);
// this.implicitInputs[frontKey] = data[frontKey];
const { notationMap } = obj_util_1.getValuesByWildCardStringNotation(data);
const keys = Object.keys(notationMap);
const len = keys.length;
let i = 0;
for (i; i < len; i += 1) {
const key = keys[i];
const attrRules = this.parsedRulesCollection[key];
if (attrRules /*&& key.indexOf('*') >= 0*/) {
notationMap[key].forEach((attrName) => {
this.parsedRulesCollection[attrName] = attrRules;
});
}
}
}
parseInputs() {
if (!this.hasNestedRules) {
return;
}
// const flat = (data: any, prepend = '') => {
// const results: any = {};
// Object.keys(data).forEach(key => {
// const value = data[key];
// if (typeof value === 'object') {
// results.push(...results, ...flat(value, prepend + key + '.'));
// } else {
// results[prepend + key] = value;
// }
// });
// return results;
// if (!this.hasNestedRules) {
// return;
// }
Object.keys(this.rules).forEach((key) => {
if (key.indexOf('*') >= 0) {
this.fillMissingAttributes(key);
}
});
// const { notationMap, notationsVals } = getValuesByWildCardStringNotation(
// this.inputs, this.rules,
// );
// this.notationMap = notationMap;
// this.notationVals = notationsVals;
// const keys = Object.keys(this.notationMap);
// const len = keys.length;
// let i = 0;
// for (i; i < len; i += 1) {
// const key = keys[i];
// const attrRules: Array<ValidationRuleContract> = this.parsedRulesCollection[key];
// if (attrRules && key.indexOf('*') >= 0) {
// this.notationMap[key].forEach((attrName: string) => {
// this.parsedRulesCollection[attrName] = attrRules;
// });
// }
// }
}

@@ -288,2 +243,3 @@ /**

}
// console.log(JSON.stringify(this.parsedRulesCollection, null, 2))
const keys = Object.keys(this.parsedRulesCollection);

@@ -295,8 +251,3 @@ const len = keys.length;

const attrName = keys[i];
if (attrName.indexOf('*') < 0) {
const attrRules = this.parsedRulesCollection[attrName];
if (attrRules) {
promises.push(this.validateAttribute(attrName, attrRules));
}
}
promises.push(this.applyParsedRules(attrName, this.parsedRulesCollection[attrName], this.inputs));
}

@@ -310,2 +261,32 @@ // post validation rules

}
async applyParsedRules(attrName, rules, inputs, prefix = '') {
if (attrName === '*') {
if (!Array.isArray(inputs)) {
// this.createAttributeError({
// attrName,
// attrValue: inputs,
// ruleName: 'array',
// ruleArgs: [],
// });
return;
}
let i = 0;
for (const val of inputs) {
// console.log(i, rules, [val], `${prefix}${i}`);
await this.applyParsedRules(i, rules, inputs, prefix);
i += 1;
}
return;
}
const attrValue = inputs[attrName];
const info = await this.validateAttribute(attrName, attrValue, rules.rules, { prefix, inputs });
//console.log(attrName, attrValue, info)
if (info.empty && info.passed) {
return;
}
for (const cattrName in rules.child) {
await this.applyParsedRules(cattrName, rules.child[cattrName], attrValue || {}, prefix.length ? `${prefix}${attrName}.` : `${attrName}.`);
// break;
}
}
/**

@@ -316,3 +297,9 @@ * apply rules on attribute

*/
async validateAttribute(attrName, attrRules) {
async validateAttribute(attrName, attrValue, attrRules, { prefix, inputs }) {
const info = {
implicit: false,
implicitFailed: false,
passed: true,
empty: ops_util_js_1.reallyEmpty(attrValue),
};
let i = 0;

@@ -322,26 +309,21 @@ let len = attrRules.length;

const validationRule = attrRules[i];
let attrValue = this.attributeValue(attrName);
if (
// no implicit rule and attribute value is empty
(this.implicitRules.indexOf(validationRule.name) < 0 &&
ops_util_1.reallyEmpty(attrValue))
// attribute can be nullable
// (validationRule.name === "nullable" && attrValue === null) ||
// // attribute will only be validated if presents
// (validationRule.name === "sometimes" &&
// this.isAttributePresent(attrName) === false)
) {
const isImplicitRule = this.implicitRules.indexOf(validationRule.name) >= 0;
if (isImplicitRule) {
info.implicit = true;
}
if (!isImplicitRule && info.empty) {
if (this.isBailable()) {
// console.log(' here i m ...');
return;
return info;
}
attrValue = '';
}
// console.log(this.breakWhenFailed, this.isBailable());
const passed = await validationRule.handler(attrValue, this, attrName);
const passed = await validationRule.handler(attrValue, this, attrName, { path: prefix + attrName, inputs });
if (passed == -1) {
continue;
}
this.shouldRelease = false;
// console.log('attr', attrName, validationRule.name, passed);
if (!passed) {
info.passed = false;
this.createAttributeError({
attrName,
attrName: prefix + attrName,
attrValue,

@@ -352,6 +334,7 @@ ruleName: validationRule.name,

if (this.isBailable()) {
return;
return info;
}
}
}
return info;
}

@@ -413,3 +396,3 @@ /**

}
return message_parser_util_1.messageParser({
return message_parser_util_js_1.messageParser({
message,

@@ -428,3 +411,3 @@ attrName: attributeName,

attributeValue(attr) {
return obj_util_1.getValueByStringNotation(this.inputs, attr);
return obj_util_js_1.getValueByStringNotation(this.inputs, attr);
// return this.inputs[attr] || this.notationVals[attr];

@@ -444,3 +427,3 @@ }

isAttributePresent(attr) {
if (this.inputs[attr]) {
if (this.inputs[attr] != undefined) {
return true;

@@ -447,0 +430,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidatorLite = exports.registerRules = void 0;
const validator_abstract_1 = require("./validator-abstract");
Object.defineProperty(exports, "registerRules", { enumerable: true, get: function () { return validator_abstract_1.registerRules; } });
class ValidatorLite extends validator_abstract_1.ValidatorAbstract {
const validator_abstract_js_1 = require("./validator-abstract.js");
Object.defineProperty(exports, "registerRules", { enumerable: true, get: function () { return validator_abstract_js_1.registerRules; } });
class ValidatorLite extends validator_abstract_js_1.ValidatorAbstract {
}
exports.ValidatorLite = ValidatorLite;
//# sourceMappingURL=validator-lite.js.map

@@ -23,12 +23,12 @@ "use strict";

exports.Validator = void 0;
const Rules = __importStar(require("./rules"));
const PostRules = __importStar(require("./post-rules"));
require("./messages");
const date_1 = require("./date");
const validator_abstract_1 = require("./validator-abstract");
validator_abstract_1.registerRules(Rules);
validator_abstract_1.registerPostRules(PostRules);
class Validator extends validator_abstract_1.ValidatorAbstract {
const Rules = __importStar(require("./rules/index.js"));
const PostRules = __importStar(require("./post-rules/index.js"));
require("./messages/index.js");
const index_js_1 = require("./date/index.js");
const validator_abstract_js_1 = require("./validator-abstract.js");
validator_abstract_js_1.registerRules(Rules);
validator_abstract_js_1.registerPostRules(PostRules);
class Validator extends validator_abstract_js_1.ValidatorAbstract {
dateAdapter() {
return date_1.dateAdapter();
return index_js_1.dateAdapter();
}

@@ -35,0 +35,0 @@ }

@@ -1,2 +0,2 @@

import { Langs } from "./contracts";
import { Langs } from "./contracts.js";
let config = {

@@ -3,0 +3,0 @@ wildcardIterations: 1000,

@@ -1,2 +0,2 @@

import { DateAdapter } from "./contracts";
import { DateAdapter } from "./contracts.js";
export class DateFnsAdapter extends DateAdapter {

@@ -3,0 +3,0 @@ constructor(dateLib) {

@@ -1,5 +0,5 @@

import { DateAdapter } from "./contracts";
import { get } from '../config';
export * from './date-fns.adapter';
export * from './moment.adapter';
import { DateAdapter } from "./contracts.js";
import { get } from '../config.js';
export * from './date-fns.adapter.js';
export * from './moment.adapter.js';
export { DateAdapter };

@@ -6,0 +6,0 @@ export function dateAdapter() {

@@ -1,2 +0,2 @@

import { DateAdapter } from "./contracts";
import { DateAdapter } from "./contracts.js";
export class MomentAdapter extends DateAdapter {

@@ -3,0 +3,0 @@ constructor(dateLib) {

@@ -1,8 +0,8 @@

export * from './contracts';
export * as Messages from './messages';
import * as Rules from './rules';
import { Validator } from './validator';
export * from './contracts.js';
export * as Messages from './messages/index.js';
import * as Rules from './rules/index.js';
import { Validator } from './validator.js';
export { Validator, Rules };
export { MomentAdapter, DateFnsAdapter } from './date';
import * as config from "./config";
export { MomentAdapter, DateFnsAdapter } from './date/index.js';
import * as config from "./config.js";
export function configure(customConf) {

@@ -9,0 +9,0 @@ config.set(customConf);

@@ -1,3 +0,3 @@

export * as Messages from './messages';
export * from './provider';
export * as Messages from './messages.js';
export * from './provider.js';
//# sourceMappingURL=index.js.map

@@ -1,6 +0,6 @@

import { Langs } from "../contracts";
import * as en_US from "./en-US.messages";
import { extend } from './provider';
import { Langs } from "../contracts.js";
import * as en_US from "./en-US.messages.js";
import { extend } from './provider.js';
extend(en_US.messages, Langs.en_US);
export { en_US };
//# sourceMappingURL=messages.js.map

@@ -1,3 +0,3 @@

import { getKeyValue } from "../utils/obj.util";
import { Langs } from "../contracts";
import { getKeyValue } from "../utils/obj.util.js";
import { Langs } from "../contracts.js";
export const DEFAULT_LANG = Langs.en_US;

@@ -4,0 +4,0 @@ const MessagesRef = {};

@@ -27,3 +27,3 @@ export function all(args) {

v.createAttributeError({
ruleName: 'any',
ruleName: 'all',
attrName: '*',

@@ -30,0 +30,0 @@ attrValue: values,

export function any(args) {
return {
name: 'all',
name: 'any',
handler: (_, v) => {

@@ -5,0 +5,0 @@ // @ts-ignore

@@ -1,3 +0,3 @@

export * from './all';
export * from './any';
export * from './all.js';
export * from './any.js';
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { reallyEmpty } from "../utils/ops.util";
import { reallyEmpty } from "../utils/ops.util.js";
/**

@@ -3,0 +3,0 @@ * The field under validation must be yes, on, 1, or true.

@@ -1,2 +0,2 @@

import { isNumeric } from "../utils/number.util";
import { isNumeric } from "../utils/number.util.js";
/**

@@ -3,0 +3,0 @@ * The field under validation must be between min and max seed.

@@ -1,2 +0,2 @@

import { isCreditCard } from "../utils/borrowed";
import { isCreditCard } from "../utils/borrowed.js";
export function creditCard() {

@@ -3,0 +3,0 @@ return {

@@ -1,2 +0,2 @@

import { dateAdapter } from "../date";
import { dateAdapter } from "../date/index.js";
export function dateAfter(args) {

@@ -3,0 +3,0 @@ if (args.length !== 2) {

@@ -1,2 +0,2 @@

import { isInt } from '../utils/number.util';
import { isInt } from '../utils/number.util.js';
export function digits(args = []) {

@@ -3,0 +3,0 @@ if (args.length !== 1) {

@@ -1,2 +0,2 @@

import { isDomain } from "../utils/borrowed";
import { isDomain } from "../utils/borrowed.js";
export function domain() {

@@ -3,0 +3,0 @@ return {

@@ -1,2 +0,2 @@

import { isEmail } from "../utils/borrowed";
import { isEmail } from "../utils/borrowed.js";
export function email() {

@@ -3,0 +3,0 @@ return {

@@ -1,2 +0,2 @@

import { isHexadecimal } from "../utils/str.util";
import { isHexadecimal } from "../utils/str.util.js";
const hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;

@@ -3,0 +3,0 @@ const hexadecimal = /^(0x|0h)?[0-9A-F]+$/i;

export function _in(args) {
if (!args.length) {
if (!args || !args.length) {
throw new Error('Invalid number of arguments.');

@@ -4,0 +4,0 @@ }

@@ -1,39 +0,39 @@

export * from './accepted.rule';
export * from './alpha.rule';
export * from './array.rule';
export * from './between.rule';
export * from './boolean.rule';
export * from './confirmed.rule';
export * from './contains.rule';
export * from './creditCard.rule';
export * from './date.rule';
export * from './dateiso.rule';
export * from './different.rule';
export * from './digits.rule';
export * from './domain.rule';
export * from './email.rule';
export * from './encoding.rule';
export * from './equals.rule';
export * from './gt.rule';
export * from './hash.rule';
export * from './hex.rule';
export { _in as in, notIn } from './in.rule';
export * from './ip.rule';
export * from './latLong.rule';
export * from './length.rule';
export * from './lt.rule';
export * from './macAddress.rule';
export * from './mime.rule';
export * from './mongoId.rule';
export * from './number.rule';
export * from './object.rule';
export * from './phoneNumber.rule';
export * from './regex.rule';
export * from './required.rule';
export * from './same.rule';
export * from './size.rule';
export * from './special.rule';
export * from './string.rule';
export * from './url.rule';
export * from './validator.rule';
export * from './accepted.rule.js';
export * from './alpha.rule.js';
export * from './array.rule.js';
export * from './between.rule.js';
export * from './boolean.rule.js';
export * from './confirmed.rule.js';
export * from './contains.rule.js';
export * from './creditCard.rule.js';
export * from './date.rule.js';
export * from './dateiso.rule.js';
export * from './different.rule.js';
export * from './digits.rule.js';
export * from './domain.rule.js';
export * from './email.rule.js';
export * from './encoding.rule.js';
export * from './equals.rule.js';
export * from './gt.rule.js';
export * from './hash.rule.js';
export * from './hex.rule.js';
export { _in as in, notIn } from './in.rule.js';
export * from './ip.rule.js';
export * from './latLong.rule.js';
export * from './length.rule.js';
export * from './lt.rule.js';
export * from './macAddress.rule.js';
export * from './mime.rule.js';
export * from './mongoId.rule.js';
export * from './number.rule.js';
export * from './object.rule.js';
export * from './phoneNumber.rule.js';
export * from './regex.rule.js';
export * from './required.rule.js';
export * from './same.rule.js';
export * from './size.rule.js';
export * from './special.rule.js';
export * from './string.rule.js';
export * from './url.rule.js';
export * from './validator.rule.js';
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { isIp } from '../utils/borrowed';
import { isIp } from '../utils/borrowed.js';
export function ip(args = []) {

@@ -3,0 +3,0 @@ return {

@@ -1,2 +0,2 @@

import { isHexadecimal } from "../utils/str.util";
import { isHexadecimal } from "../utils/str.util.js";
export function mongoId() {

@@ -3,0 +3,0 @@ return {

@@ -1,2 +0,2 @@

import { isDecimal, isInt, isNumeric } from '../utils/number.util';
import { isDecimal, isInt, isNumeric } from '../utils/number.util.js';
export function integer(args = []) {

@@ -3,0 +3,0 @@ return {

@@ -1,2 +0,2 @@

import { reallyEmpty } from "../utils/ops.util";
import { reallyEmpty } from "../utils/ops.util.js";
export function required() {

@@ -3,0 +3,0 @@ return {

import fs from 'fs';
import util from 'util';
import { sizeToBytes } from '../utils/str.util';
import { sizeToBytes } from '../utils/str.util.js';
/**

@@ -5,0 +5,0 @@ * check if bytes are within given range

@@ -5,2 +5,5 @@ export function nullable() {

handler: (value) => {
if (value != null) {
return -1;
}
return true;

@@ -13,3 +16,6 @@ },

name: "sometimes",
handler: (value) => {
handler: (value, v, name, { inputs }) => {
if (inputs[name] != undefined) {
return -1;
}
return true;

@@ -16,0 +22,0 @@ },

@@ -1,2 +0,2 @@

import { camelCaseToSentance, snakeCaseToSentance } from './str.util';
import { camelCaseToSentance, snakeCaseToSentance } from './str.util.js';
export function messageParser(params) {

@@ -3,0 +3,0 @@ const { message, attrName, niceName, ruleArgs, ruleName, attrValue } = params;

@@ -1,2 +0,2 @@

import * as config from '../config';
import * as config from '../config.js';
export function getKeyValue(key) {

@@ -3,0 +3,0 @@ return (obj) => obj[key];

@@ -1,2 +0,2 @@

import { isObject } from './obj.util';
import { isObject } from './obj.util.js';
export function reallyEmpty(value) {

@@ -3,0 +3,0 @@ const str = (value === undefined || value === null ? "" : value) + "";

@@ -1,2 +0,2 @@

import { getKeyValue } from "./obj.util";
import { getKeyValue } from "./obj.util.js";
/**

@@ -3,0 +3,0 @@ * parse rules those are in string notation

@@ -1,7 +0,7 @@

import { messageParser } from "./utils/message-parser.util";
import { reallyEmpty, fillMissingSpots } from "./utils/ops.util";
import { getValueByStringNotation, getValuesByWildCardStringNotation } from "./utils/obj.util";
import { parseStringNotationRules, parseStringRule } from "./utils/rules-parser.util";
import * as MessagesProvider from './messages/provider';
import * as config from './config';
import { messageParser } from "./utils/message-parser.util.js";
import { reallyEmpty } from "./utils/ops.util.js";
import { getValueByStringNotation } from "./utils/obj.util.js";
import { parseStringNotationRules, parseStringRule } from "./utils/rules-parser.util.js";
import * as MessagesProvider from './messages/provider.js';
import * as config from './config.js';
let RulesProvider = {};

@@ -153,88 +153,43 @@ let PostRulesProvider = {};

parseRules() {
let attr;
for (attr of Object.keys(this.rules)) {
if (attr === '*') {
this.addPostRules(this.rules[attr]);
return;
const keys = Object.keys(this.rules);
const parsed = {};
for (const key of keys) {
if (key === '*') {
this.addPostRules(this.rules[key]);
continue;
}
if (attr.indexOf(".")) {
this.hasNestedRules = true;
let rules = this.rules[key];
if (Array.isArray(rules)) {
for (const index in rules) {
if (typeof rules[index] == 'string') {
rules[index] = parseStringRule(RulesProvider, rules[index]);
}
}
}
const attrRules = this.rules[attr];
if (typeof attrRules === 'string') {
this.parsedRulesCollection[attr] = parseStringNotationRules(RulesProvider, attrRules);
}
else {
attrRules.forEach((strRule, index) => {
if (typeof strRule === 'string') {
attrRules[index] = parseStringRule(RulesProvider, strRule);
}
});
// @ts-ignore
this.parsedRulesCollection[attr] = attrRules;
rules = parseStringNotationRules(RulesProvider, rules);
}
// sort rules as
this.parsedRulesCollection[attr].sort((obj) => {
rules.sort((obj) => {
return (this.implicitRules.indexOf(obj.name) >= 0) ? -1 : 1;
});
let kobj = parsed;
let path = '';
key.split('.').forEach((k, i) => {
path += k;
if (!kobj[k]) {
kobj[k] = {
rules: this.rules[path] ? rules : [],
child: {},
};
}
kobj = kobj[k].child;
path += '.';
});
}
this.parsedRulesCollection = parsed;
}
fillMissingAttributes(key) {
const data = {};
const [frontKey] = key.split('.');
data[frontKey] = this.inputs[frontKey];
fillMissingSpots(data, key);
// this.implicitInputs[frontKey] = data[frontKey];
const { notationMap } = getValuesByWildCardStringNotation(data);
const keys = Object.keys(notationMap);
const len = keys.length;
let i = 0;
for (i; i < len; i += 1) {
const key = keys[i];
const attrRules = this.parsedRulesCollection[key];
if (attrRules /*&& key.indexOf('*') >= 0*/) {
notationMap[key].forEach((attrName) => {
this.parsedRulesCollection[attrName] = attrRules;
});
}
}
}
parseInputs() {
if (!this.hasNestedRules) {
return;
}
// const flat = (data: any, prepend = '') => {
// const results: any = {};
// Object.keys(data).forEach(key => {
// const value = data[key];
// if (typeof value === 'object') {
// results.push(...results, ...flat(value, prepend + key + '.'));
// } else {
// results[prepend + key] = value;
// }
// });
// return results;
// if (!this.hasNestedRules) {
// return;
// }
Object.keys(this.rules).forEach((key) => {
if (key.indexOf('*') >= 0) {
this.fillMissingAttributes(key);
}
});
// const { notationMap, notationsVals } = getValuesByWildCardStringNotation(
// this.inputs, this.rules,
// );
// this.notationMap = notationMap;
// this.notationVals = notationsVals;
// const keys = Object.keys(this.notationMap);
// const len = keys.length;
// let i = 0;
// for (i; i < len; i += 1) {
// const key = keys[i];
// const attrRules: Array<ValidationRuleContract> = this.parsedRulesCollection[key];
// if (attrRules && key.indexOf('*') >= 0) {
// this.notationMap[key].forEach((attrName: string) => {
// this.parsedRulesCollection[attrName] = attrRules;
// });
// }
// }
}

@@ -263,2 +218,3 @@ /**

}
// console.log(JSON.stringify(this.parsedRulesCollection, null, 2))
const keys = Object.keys(this.parsedRulesCollection);

@@ -270,8 +226,3 @@ const len = keys.length;

const attrName = keys[i];
if (attrName.indexOf('*') < 0) {
const attrRules = this.parsedRulesCollection[attrName];
if (attrRules) {
promises.push(this.validateAttribute(attrName, attrRules));
}
}
promises.push(this.applyParsedRules(attrName, this.parsedRulesCollection[attrName], this.inputs));
}

@@ -285,2 +236,32 @@ // post validation rules

}
async applyParsedRules(attrName, rules, inputs, prefix = '') {
if (attrName === '*') {
if (!Array.isArray(inputs)) {
// this.createAttributeError({
// attrName,
// attrValue: inputs,
// ruleName: 'array',
// ruleArgs: [],
// });
return;
}
let i = 0;
for (const val of inputs) {
// console.log(i, rules, [val], `${prefix}${i}`);
await this.applyParsedRules(i, rules, inputs, prefix);
i += 1;
}
return;
}
const attrValue = inputs[attrName];
const info = await this.validateAttribute(attrName, attrValue, rules.rules, { prefix, inputs });
//console.log(attrName, attrValue, info)
if (info.empty && info.passed) {
return;
}
for (const cattrName in rules.child) {
await this.applyParsedRules(cattrName, rules.child[cattrName], attrValue || {}, prefix.length ? `${prefix}${attrName}.` : `${attrName}.`);
// break;
}
}
/**

@@ -291,3 +272,9 @@ * apply rules on attribute

*/
async validateAttribute(attrName, attrRules) {
async validateAttribute(attrName, attrValue, attrRules, { prefix, inputs }) {
const info = {
implicit: false,
implicitFailed: false,
passed: true,
empty: reallyEmpty(attrValue),
};
let i = 0;

@@ -297,26 +284,21 @@ let len = attrRules.length;

const validationRule = attrRules[i];
let attrValue = this.attributeValue(attrName);
if (
// no implicit rule and attribute value is empty
(this.implicitRules.indexOf(validationRule.name) < 0 &&
reallyEmpty(attrValue))
// attribute can be nullable
// (validationRule.name === "nullable" && attrValue === null) ||
// // attribute will only be validated if presents
// (validationRule.name === "sometimes" &&
// this.isAttributePresent(attrName) === false)
) {
const isImplicitRule = this.implicitRules.indexOf(validationRule.name) >= 0;
if (isImplicitRule) {
info.implicit = true;
}
if (!isImplicitRule && info.empty) {
if (this.isBailable()) {
// console.log(' here i m ...');
return;
return info;
}
attrValue = '';
}
// console.log(this.breakWhenFailed, this.isBailable());
const passed = await validationRule.handler(attrValue, this, attrName);
const passed = await validationRule.handler(attrValue, this, attrName, { path: prefix + attrName, inputs });
if (passed == -1) {
continue;
}
this.shouldRelease = false;
// console.log('attr', attrName, validationRule.name, passed);
if (!passed) {
info.passed = false;
this.createAttributeError({
attrName,
attrName: prefix + attrName,
attrValue,

@@ -327,6 +309,7 @@ ruleName: validationRule.name,

if (this.isBailable()) {
return;
return info;
}
}
}
return info;
}

@@ -417,3 +400,3 @@ /**

isAttributePresent(attr) {
if (this.inputs[attr]) {
if (this.inputs[attr] != undefined) {
return true;

@@ -420,0 +403,0 @@ }

@@ -1,2 +0,2 @@

import { ValidatorAbstract, registerRules } from "./validator-abstract";
import { ValidatorAbstract, registerRules } from "./validator-abstract.js";
export { registerRules };

@@ -3,0 +3,0 @@ export class ValidatorLite extends ValidatorAbstract {

@@ -1,6 +0,6 @@

import * as Rules from './rules';
import * as PostRules from './post-rules';
import './messages';
import { dateAdapter } from "./date";
import { ValidatorAbstract, registerRules, registerPostRules } from "./validator-abstract";
import * as Rules from './rules/index.js';
import * as PostRules from './post-rules/index.js';
import './messages/index.js';
import { dateAdapter } from "./date/index.js";
import { ValidatorAbstract, registerRules, registerPostRules } from "./validator-abstract.js";
registerRules(Rules);

@@ -7,0 +7,0 @@ registerPostRules(PostRules);

@@ -5,2 +5,14 @@ module.exports = {

roots: ["<rootDir>/src/"],
transform: {
'\\.[jt]sx?$': 'ts-jest'
},
globals: {
'ts-jest': {
useESM: true
}
},
moduleNameMapper: {
'(.+)\\.js': '$1'
},
extensionsToTreatAsEsm: ['.ts'],
};
{
"name": "node-input-validator",
"version": "5.0.0-beta.5",
"version": "5.0.0-beta.6",
"description": "validation library for nodejs, inspired by laravel.",

@@ -32,5 +32,4 @@ "main": "./cjs/index.js",

"ts-jest": "^26.4.4",
"tsc": "^2.0.3",
"typedoc": "^0.20.16",
"typescript": "^3.9.7",
"typescript": "^3.9.10",
"validator": "^13.5.2"

@@ -37,0 +36,0 @@ },

@@ -20,3 +20,3 @@ # NIV (Node Input Validator)

[npm-image]: https://img.shields.io/npm/v/node-input-validator/beta?style=flat-square
[npm-url]: https://www.npmjs.com/package/node-input-validator/v/5.0.0-beta.0
[npm-url]: https://www.npmjs.com/package/node-input-validator/v/5.0.0-beta.6

@@ -30,2 +30,5 @@ [node-image]: https://img.shields.io/badge/node.js-%3E=_10.12-green.svg?style=flat-square

> There are some major changes in nested fields validations and some rules behaviour. Will update documentation soon.
> Post validations rules are broken
## Installation

@@ -494,5 +497,4 @@

## Roadblock
### v5.0.0-beta.5
- fillMissingSpots overwriting array value in nested inputs, eg. product.attributes.*.colors.*
/// <reference types="node" />
import { Langs } from "./contracts";
import { DateAdapter } from "./date/contracts";
import { Langs } from "./contracts.js";
import { DateAdapter } from "./date/contracts.js";
export interface IConfig extends NodeJS.Dict<any> {

@@ -5,0 +5,0 @@ wildcardIterations?: number;

@@ -1,2 +0,2 @@

import { DateAdapter } from "./contracts";
import { DateAdapter } from "./contracts.js";
export declare class DateFnsAdapter extends DateAdapter {

@@ -3,0 +3,0 @@ protected dateLib: any;

@@ -1,5 +0,5 @@

import { DateAdapter } from "./contracts";
export * from './date-fns.adapter';
export * from './moment.adapter';
import { DateAdapter } from "./contracts.js";
export * from './date-fns.adapter.js';
export * from './moment.adapter.js';
export { DateAdapter };
export declare function dateAdapter(): DateAdapter;

@@ -1,2 +0,2 @@

import { DateAdapter } from "./contracts";
import { DateAdapter } from "./contracts.js";
export declare class MomentAdapter extends DateAdapter {

@@ -3,0 +3,0 @@ protected dateLib: any;

@@ -1,10 +0,10 @@

export * from './contracts';
export * as Messages from './messages';
import * as Rules from './rules';
import { Validator } from './validator';
export * from './contracts.js';
export * as Messages from './messages/index.js';
import * as Rules from './rules/index.js';
import { Validator } from './validator.js';
export { Validator, Rules };
export { MomentAdapter, DateFnsAdapter } from './date';
import { Langs, ValidationRuleContract } from './contracts';
import * as config from "./config";
import { DateAdapter } from './date/contracts';
export { MomentAdapter, DateFnsAdapter } from './date/index.js';
import { Langs, ValidationRuleContract } from './contracts.js';
import * as config from "./config.js";
import { DateAdapter } from './date/contracts.js';
export declare function configure(customConf: config.IConfig): void;

@@ -11,0 +11,0 @@ export declare function useDateAdapter(dateAdapter: DateAdapter): void;

@@ -1,2 +0,2 @@

export * as Messages from './messages';
export * from './provider';
export * as Messages from './messages.js';
export * from './provider.js';

@@ -1,2 +0,2 @@

import * as en_US from "./en-US.messages";
import * as en_US from "./en-US.messages.js";
export { en_US };

@@ -1,2 +0,2 @@

import { Langs, MessagesContract, MessagesDictContract } from "../contracts";
import { Langs, MessagesContract, MessagesDictContract } from "../contracts.js";
export declare const DEFAULT_LANG: Langs;

@@ -3,0 +3,0 @@ export declare function messagesRefByLang(lang: Langs): any;

@@ -1,2 +0,2 @@

import { AttributeValidationMinimalInfo, ValidatorContract } from "../contracts";
import { AttributeValidationMinimalInfo, ValidatorContract } from "../contracts.js";
export declare class ValidatorMock implements ValidatorContract {

@@ -3,0 +3,0 @@ private inputs;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function all(args: Array<string>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function any(args: Array<string>): ValidationRuleContract;

@@ -1,2 +0,2 @@

export * from './all';
export * from './any';
export * from './all.js';
export * from './any.js';

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
/**

@@ -3,0 +3,0 @@ * The field under validation must be yes, on, 1, or true.

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
/**

@@ -3,0 +3,0 @@ * The field under validation must be entirely alphabetic characters.

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
/**

@@ -3,0 +3,0 @@ * The field under validation must be array.

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
/**

@@ -3,0 +3,0 @@ * The field under validation must be between min and max seed.

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function booleanStr(): ValidationRuleContract;

@@ -3,0 +3,0 @@ export declare function booleanInt(): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function confirmed(args?: Array<string>): ValidationRuleContract;

@@ -1,3 +0,3 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function contains(args: Array<string>): ValidationRuleContract;
export declare function notContains(args: Array<any>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function creditCard(): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function dateAfter(args: Array<Date | string | number>): ValidationRuleContract;

@@ -3,0 +3,0 @@ export declare function after(args: Array<Date | string | number>): ValidationRuleContract;

@@ -1,3 +0,3 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function dateiso(): ValidationRuleContract;
export declare function iso8601(): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function different(args: Array<any>): ValidationRuleContract;

@@ -1,3 +0,3 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function digits(args?: Array<string>): ValidationRuleContract;
export declare function digitsBetween(args?: Array<string>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function domain(): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function email(): ValidationRuleContract;

@@ -1,4 +0,4 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function ascii(): ValidationRuleContract;
export declare function json(): ValidationRuleContract;
export declare function base64(args?: Array<'urlsafe'>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function equals(args: Array<string>): ValidationRuleContract;

@@ -1,3 +0,3 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function gt(args: Array<string>): ValidationRuleContract;
export declare function gte(args: Array<any>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function hash(args: Array<any>): ValidationRuleContract;

@@ -1,3 +0,3 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function hex(): ValidationRuleContract;
export declare function hexColor(): ValidationRuleContract;

@@ -1,3 +0,3 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function sometimes(): ValidationRuleContract;
export declare function nullable(): ValidationRuleContract;

@@ -1,3 +0,3 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function _in(args: Array<any>): ValidationRuleContract;
export declare function notIn(args: Array<any>): ValidationRuleContract;

@@ -1,38 +0,38 @@

export * from './accepted.rule';
export * from './alpha.rule';
export * from './array.rule';
export * from './between.rule';
export * from './boolean.rule';
export * from './confirmed.rule';
export * from './contains.rule';
export * from './creditCard.rule';
export * from './date.rule';
export * from './dateiso.rule';
export * from './different.rule';
export * from './digits.rule';
export * from './domain.rule';
export * from './email.rule';
export * from './encoding.rule';
export * from './equals.rule';
export * from './gt.rule';
export * from './hash.rule';
export * from './hex.rule';
export { _in as in, notIn } from './in.rule';
export * from './ip.rule';
export * from './latLong.rule';
export * from './length.rule';
export * from './lt.rule';
export * from './macAddress.rule';
export * from './mime.rule';
export * from './mongoId.rule';
export * from './number.rule';
export * from './object.rule';
export * from './phoneNumber.rule';
export * from './regex.rule';
export * from './required.rule';
export * from './same.rule';
export * from './size.rule';
export * from './special.rule';
export * from './string.rule';
export * from './url.rule';
export * from './validator.rule';
export * from './accepted.rule.js';
export * from './alpha.rule.js';
export * from './array.rule.js';
export * from './between.rule.js';
export * from './boolean.rule.js';
export * from './confirmed.rule.js';
export * from './contains.rule.js';
export * from './creditCard.rule.js';
export * from './date.rule.js';
export * from './dateiso.rule.js';
export * from './different.rule.js';
export * from './digits.rule.js';
export * from './domain.rule.js';
export * from './email.rule.js';
export * from './encoding.rule.js';
export * from './equals.rule.js';
export * from './gt.rule.js';
export * from './hash.rule.js';
export * from './hex.rule.js';
export { _in as in, notIn } from './in.rule.js';
export * from './ip.rule.js';
export * from './latLong.rule.js';
export * from './length.rule.js';
export * from './lt.rule.js';
export * from './macAddress.rule.js';
export * from './mime.rule.js';
export * from './mongoId.rule.js';
export * from './number.rule.js';
export * from './object.rule.js';
export * from './phoneNumber.rule.js';
export * from './regex.rule.js';
export * from './required.rule.js';
export * from './same.rule.js';
export * from './size.rule.js';
export * from './special.rule.js';
export * from './string.rule.js';
export * from './url.rule.js';
export * from './validator.rule.js';

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function ip(args?: Array<'4' | '6'>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function latLong(args?: Array<'dms'>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function maxLength(args: Array<string>): ValidationRuleContract;

@@ -3,0 +3,0 @@ export declare function minLength(args: Array<string>): ValidationRuleContract;

@@ -1,3 +0,3 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function lt(args: Array<string>): ValidationRuleContract;
export declare function lte(args: Array<any>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function macAddress(): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function mime(args: Array<string>, trust?: boolean): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function mongoId(): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function integer(args?: Array<'0'>): ValidationRuleContract;

@@ -3,0 +3,0 @@ export declare function min(args: Array<string>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function object(): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function phoneNumber(args?: Array<string>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function regex(args: Array<any>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function required(): ValidationRuleContract;

@@ -3,0 +3,0 @@ export declare function requiredIf(args: Array<string>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function same(args: Array<string>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
/**

@@ -3,0 +3,0 @@ * The field under validation should be file path, Buffer or File object.

@@ -1,3 +0,3 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function nullable(): ValidationRuleContract;
export declare function sometimes(): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function string(): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
export declare function url(args?: Array<string>): ValidationRuleContract;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
/**

@@ -3,0 +3,0 @@ * @since v5

@@ -1,2 +0,2 @@

import { MessageProviderFuncation } from '../contracts';
import { MessageProviderFuncation } from '../contracts.js';
interface MessageParserParams {

@@ -3,0 +3,0 @@ message: string | MessageProviderFuncation;

@@ -1,2 +0,2 @@

import { ValidationRuleContract } from "../contracts";
import { ValidationRuleContract } from "../contracts.js";
/**

@@ -3,0 +3,0 @@ * parse rules those are in string notation

/// <reference types="node" />
import { Langs, AttributeValidationMinimalInfo, ValidationRuleContract, ValidationRulesContract, ValidationRuleStringNotationContract, MessagesContract, NiceNamesContract, ValidatorErrorContract, ValidatorErrorsContract, ValidationRuleArrayStringNotationContract } from "./contracts";
import { Langs, AttributeValidationMinimalInfo, ValidationRuleContract, ValidationRulesContract, ValidationRuleStringNotationContract, MessagesContract, NiceNamesContract, ValidatorErrorContract, ValidatorErrorsContract, ValidationRuleArrayStringNotationContract } from "./contracts.js";
/**

@@ -81,3 +81,2 @@ * registerRules will replace old registered rules

parseRules(): void;
fillMissingAttributes(key: string): void;
parseInputs(): void;

@@ -98,2 +97,3 @@ /**

validate(inputs?: any): Promise<boolean>;
applyParsedRules(attrName: any, rules: any, inputs: any, prefix?: string): Promise<void>;
/**

@@ -104,3 +104,8 @@ * apply rules on attribute

*/
validateAttribute(attrName: string, attrRules: Array<ValidationRuleContract>): Promise<void>;
validateAttribute(attrName: string, attrValue: any, attrRules: Array<ValidationRuleContract>, { prefix, inputs }: any): Promise<{
implicit: boolean;
implicitFailed: boolean;
passed: boolean;
empty: boolean;
}>;
/**

@@ -107,0 +112,0 @@ * this will create error object for attribute

@@ -1,4 +0,4 @@

import { ValidatorAbstract, registerRules } from "./validator-abstract";
import { ValidatorAbstract, registerRules } from "./validator-abstract.js";
export { registerRules };
export declare class ValidatorLite extends ValidatorAbstract {
}

@@ -1,6 +0,6 @@

import './messages';
import { DateAdapter } from "./date/contracts";
import { ValidatorAbstract } from "./validator-abstract";
import './messages/index.js';
import { DateAdapter } from "./date/contracts.js";
import { ValidatorAbstract } from "./validator-abstract.js";
export declare class Validator extends ValidatorAbstract {
dateAdapter(): DateAdapter;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc