Skip to content

0.3.0

Compare
Choose a tag to compare
@EisenbergEffect EisenbergEffect released this 10 May 20:14
· 40 commits to master since this release

Breaking changes -

Validator / Fluent API

The Validator class for the fluent API should not be injected because it should not be a singleton. The developer should switch this -

static inject = [Validator];
constructor(validator) {
  this.validator = validator
    .ensure(this.model, 'firstName')
      .required();
}

to this -

constructor() {
  this.validator = new Validator(this.model)
    .ensure('firstName')
      .required();
}

You can also see that the fluent API has been refactored to reduce duplication and clean up usage. More information is here - #17

You can also now manually validate instances that use decorators like this -

class Model {
  @required firstName = '';
}
this.model = new Model();
this.validator = new Validator(this.model);
this.validator.validate();

Fixes -

You can now pass configuration objects to all validation rules. There was previously an issue with a few of the rules mentioned here - #41