Skip to content

Commit

Permalink
fix variable name typo
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Jul 28, 2024
1 parent 8582aef commit e5dbc2e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Validator {
}

if (opts.customFunctions) {
for (const customeName in opts.customFunctions) this.addCustomFunction(customeName, opts.customFunctions[customeName]);
for (const customName in opts.customFunctions) this.addCustomFunction(customName, opts.customFunctions[customName]);
}

if (opts.plugins) {
Expand Down Expand Up @@ -445,7 +445,7 @@ class Validator {
makeCustomValidator({ vName = "value", fnName = "custom", ruleIndex, path, schema, context, messages }) {
const ruleVName = "rule" + ruleIndex;
const fnCustomErrorsVName = "fnCustomErrors" + ruleIndex;

if (typeof schema[fnName] == "function" || (Array.isArray(schema[fnName]))) {
if (context.customs[ruleIndex]) {
context.customs[ruleIndex].messages = messages;
Expand All @@ -462,9 +462,9 @@ class Validator {

if(Array.isArray(schema[fnName])){
for (let i = 0; i < schema[fnName].length; i++) {

let custom = schema[fnName][i];

if (typeof custom === "string") {
custom = this.parseShortHand(custom);
schema[fnName][i] = custom;
Expand All @@ -475,9 +475,9 @@ class Validator {

ret.push( `
const ${ruleVName}_${i} = context.customs[${customIndex}];
`);

if(custom.type){
ret.push( `
${vName} = ${context.async ? "await " : ""}context.customFunctions[${ruleVName}.schema.${fnName}[${i}].type].call(this, ${vName}, ${fnCustomErrorsVName} , ${ruleVName}_${i}.schema, "${path}", parent, context);
Expand Down

0 comments on commit e5dbc2e

Please sign in to comment.