Comparing version 0.0.6 to 0.0.7
@@ -181,2 +181,14 @@ "use strict"; | ||
/** | ||
* if ruleData has property of $name then set to name | ||
*/ | ||
let $name = false; | ||
if (ruleData.hasOwnProperty('$name')) { | ||
$name = ruleData['$name']; | ||
delete ruleData['$name']; | ||
if (typeof $name !== 'string') { | ||
throw new Error(`$skip value or resolved function value must be a BOOLEAN in RuleFor: (${rule})`); | ||
} | ||
} | ||
console.log(ruleData); | ||
/** | ||
* Append internal Wildcard data | ||
@@ -216,3 +228,3 @@ */ | ||
if (isAsync) { | ||
asyncData.jobs.push({ rule, validator, validatorName, validatorOption }); | ||
asyncData.jobs.push({ $name, rule, validator, validatorName, validatorOption }); | ||
} | ||
@@ -273,3 +285,3 @@ else { | ||
*/ | ||
let message = validator.error.replace(':param', Functions_1.UpperFirst(rule)); | ||
let message = validator.error.replace(':param', $name ? $name : Functions_1.UpperFirst(rule)); | ||
if (optionIsStringable) | ||
@@ -332,3 +344,3 @@ message = message.replace(':option', validatorOption); | ||
for (const job of jobs) { | ||
const { rule, validator, validatorName, validatorOption } = job; | ||
const { $name, rule, validator, validatorName, validatorOption } = job; | ||
/** | ||
@@ -388,3 +400,3 @@ * Value of key being validated in object | ||
*/ | ||
let message = validator.error.replace(':param', Functions_1.UpperFirst(rule)); | ||
let message = validator.error.replace(':param', $name ? $name : Functions_1.UpperFirst(rule)); | ||
if (optionIsStringable) | ||
@@ -391,0 +403,0 @@ message = message.replace(':option', validatorOption); |
{ | ||
"name": "abolish", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A javascript object validator.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -196,2 +196,17 @@ import {Validator, ValidationResult, ObjectType} from "./Types" | ||
/** | ||
* if ruleData has property of $name then set to name | ||
*/ | ||
let $name: string | false = false; | ||
if (ruleData.hasOwnProperty('$name')) { | ||
$name = ruleData['$name']; | ||
delete ruleData['$name']; | ||
if (typeof $name !== 'string') { | ||
throw new Error(`$skip value or resolved function value must be a BOOLEAN in RuleFor: (${rule})`); | ||
} | ||
} | ||
console.log(ruleData); | ||
/** | ||
* Append internal Wildcard data | ||
@@ -239,3 +254,3 @@ */ | ||
if (isAsync) { | ||
asyncData.jobs.push({rule, validator, validatorName, validatorOption}) | ||
asyncData.jobs.push({$name, rule, validator, validatorName, validatorOption}) | ||
} else { | ||
@@ -297,3 +312,3 @@ /** | ||
*/ | ||
let message = validator.error!.replace(':param', UpperFirst(rule)); | ||
let message = validator.error!.replace(':param', $name ? $name : UpperFirst(rule)); | ||
if (optionIsStringable) | ||
@@ -365,3 +380,3 @@ message = message.replace(':option', validatorOption); | ||
for (const job of jobs) { | ||
const {rule, validator, validatorName, validatorOption} = job; | ||
const {$name, rule, validator, validatorName, validatorOption} = job; | ||
@@ -425,3 +440,3 @@ /** | ||
*/ | ||
let message = validator.error!.replace(':param', UpperFirst(rule)); | ||
let message = validator.error!.replace(':param', $name ? $name : UpperFirst(rule)); | ||
if (optionIsStringable) | ||
@@ -428,0 +443,0 @@ message = message.replace(':option', validatorOption); |
70154
1900