Comparing version
25
index.js
@@ -73,2 +73,11 @@ const Joi = require('@hapi/joi'); | ||
} | ||
}, | ||
match: { | ||
method(reference) { | ||
return this.valid(joi.ref(reference)).prefs({ | ||
messages: { | ||
'any.only': `"{{#label}}" must match "${reference}"` | ||
} | ||
}).strip(); | ||
} | ||
} | ||
@@ -93,18 +102,2 @@ } | ||
} | ||
}, (joi) => { | ||
return { | ||
type: 'any', | ||
base: joi.any(), | ||
rules: { | ||
match: { | ||
method(reference) { | ||
return this.valid(joi.ref(reference)).prefs({ | ||
messages: { | ||
'any.only': `"{{#label}}" must match "${reference}"` | ||
} | ||
}).strip(); | ||
} | ||
} | ||
} | ||
} | ||
}); |
{ | ||
"name": "joi-plus", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Joi with extra rules for string and array.", | ||
@@ -5,0 +5,0 @@ "author": "Larry Png", |
@@ -14,3 +14,3 @@ # Joi-Plus | ||
* Joi.any().match(reference) | ||
* Joi.string().match(reference) | ||
-- Requires the string value to match the reference. | ||
@@ -17,0 +17,0 @@ -- Removed after validation. |
5244
-1.48%99
-6.6%