UNPKG

valirator

Version:

Powerful javascript by schema validation tool

19 lines (15 loc) 374 B
import { isDefined } from '../utils'; /** * * @param value * @param maxLength * @returns {boolean} */ export default function maxLengthRule(value, maxLength) { if (!isDefined(value)) { return true; } return value.length <= maxLength; } maxLengthRule.ruleName = 'maxLength'; maxLengthRule.defaultMessage = 'is too long (maximum is %{expected} characters)';