Pete Bacon Darwin fa11d7822c build(aio): create minLength content rule (#22759)
This rule can be used to ensure that properties contain a minimum
number of characters.

PR Close #22759
2018-04-12 00:06:49 -07:00

9 lines
275 B
JavaScript

module.exports = function createMinLengthRule(minLength) {
minLength = minLength || 2;
return (doc, prop, value) => {
if (value.length < minLength) {
return `Invalid "${prop}" property: "${value}". It must have at least ${minLength} characters.`;
}
};
};