javvi
v0.0.8
Published
Just Another Vue Validation Idea
Downloads
5
Readme
javvi
Just Another Vue Validation Idea
Install
npm install --save javvi
Introduction
It is flexible, unobtrusive, lightweight. No need for a form
, no need for submit buttons, no scoping tag.
It is as simple as just 3 mixins:
Validatable
used on components that display the error messagesJust give validatable an array of validators. Validators are objects that contains:
{ pred: 'A function that applies to model value and return boolean value', message: 'The error message when validation fails' }
So you can define custom validators with little effort. Note that the
pred
function should returntrue
on invalid model value;ValidationContainer
used on the component that triggers the validationCall
this.$doValidate
whenever to trigger validation, it will return aPromise
. If all validatables pass, this promise will be resolved, otherwise rejected.DefaultValidators
are just some frequently used validators.
Here is the example