UNPKG

vue-vuelidate-jsonschema

Version:

Create validation definitions for vuelidate based on json schema

15 lines (13 loc) 365 B
var vuelidate = require('vuelidate') var isFinite = require('lodash/isFinite') module.exports = function betweenValidator(propertySchema, min, max) { return vuelidate.withParams({ type: 'schemaBetween', min: min, max: max, schema: propertySchema }, function(val) { if (!isFinite(val)) return true return val >= min && val <= max }) }