npm vee-validate 2.0.0-beta.14

latest releases: 4.14.7, 4.14.6, 4.14.5...
8 years ago

Breaking Changes

Flags

The flags introduced in the latest version had a major change, due to them using the Proxy object which had a lot of problems in compatibility and behavior as noted #42

Now instead of using accessing the flags like objects fields.name.dirty you have to use the methods available on the fields object like this:

fields.dirty('name'); // is the field 'name' dirty?

All other flags follow suit.

additionally by not providing a field name it will return the flag status for all fields with some logical reasoning:

fields.dirty(); // Is there any field that is dirty (at least one).
fields.clean(); // Are all fields clean.
fields.valid(); // Are all fields valid.
fields.passed(); // Have all fields passed the validation.
fields.failed(); // Has any field failed the validation (at least one).

which should prove useful when validation components, additionally new methods has been added to help you modify the flag status manually:

fields.reset('name'); // resets the name flags to the original status.
fields.reset(); // resets all fields flags to their original status.

fields.setDirty('name'); // sets the dirty flag for the specified field, also modifies the dependent flags like 'clean' 'passed' and 'failed'.
fields.setValid('name'); // sets the valid flag for the specified field, also modifies the dependent flags like 'passed ' and 'failed'.

New Stuff:

Validation Reasoning:

In many scenarios you would want to change the error message depending on the result of the validation, but not all rules are black and white (true and false), sometimes you want to specify a specific reason for failing the validation. validators can now return objects instead of booleans to pass any additional data needed to the message generator, a valid object will look like this:

{
  valid: Boolean, // the validation result.
  data: { // Whatever data you want.
    // ... 
  }
}

The data property will be passed to the function generator for that validator (rule) as the third parameter:

getMessage(field, params, data) {
   // return different messages depending on the data object contents.
};

An example for this would be that your custom validation uses an API to validate the data, like checking the uniqueness of an email within your database, You can include the message in the response and attach in the data object, the message generator will then have access to the returned message from the API.

ES6 dist

A new ES6 build was added, it does not include any babel transpilation nor any Polyfills which should be ideal for those who provide their own polyfills with advanced workflow.

Bugs

  • Fixed decimal rule not allowing negative numbers #79.
  • Added translation support for confirmed target field names #46. (Still does not support data-as attribute).
  • Re-added the polyfill for Object.assign method.

Don't miss a new vee-validate release

NewReleases is sending notifications on new releases.