javvi v0.0.8
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:
Validatableused 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
predfunction should returntrueon invalid model value;ValidationContainerused on the component that triggers the validationCall
this.$doValidatewhenever to trigger validation, it will return aPromise. If all validatables pass, this promise will be resolved, otherwise rejected.DefaultValidatorsare just some frequently used validators.
Here is the example