UNPKG

vue-vuelidate-jsonschema

Version:

Create validation definitions for vuelidate based on json schema

14 lines (12 loc) 343 B
var vuelidate = require('vuelidate') var isString = require('lodash/isString') module.exports = function maxLengthValidator(propertySchema, max) { return vuelidate.withParams({ type: 'schemaMaxLength', schema: propertySchema, max: max }, function(val) { if (!isString(val)) return true return val.length <= max }) }