项目作者: peopledoc

项目描述 :
ember-cp-validations + ember-buffered-proxy
高级语言: JavaScript
项目地址: git://github.com/peopledoc/ember-cp-buffered-validations.git
创建时间: 2018-11-29T14:47:32Z
项目社区:https://github.com/peopledoc/ember-cp-buffered-validations

开源协议:MIT License

下载


ember-cp-buffered-validations

So far, using ember-cp-validations require to inject validations in the to-be-validated object.
This may be useful, but when working with DS.Model, it imposes a single validation abstraction.

This addon proposes to:

  • decouple the validator from the “validatee”
  • Applies changes to a proxy object that will carry the validation model
  • Keep using ember-cp-validations
  1. export default DS.Model.extend(buildValidations(...), {
  2. // ...
  3. })
  4. //
  5. // what we currently have
  6. //
  7. let model = this.store.findRecord('my-type', myId);
  8. console.log(model.isValid)
  9. // or
  10. export default Component.extend({
  11. model: null // will be given at runtime
  12. isEverythingOk: reads('model.isValid')
  13. })
  14. //
  15. // What we want
  16. //
  17. function doYourMagic() {
  18. this === ?
  19. }
  20. let ThingValidations = buildValidations(...)
  21. export default Component.extend({
  22. model: null // will be given at runtime
  23. validatedModel2: computed('thingTobeValidated', function () {
  24. return doYourMagic(this, 'thingTobeValidated', ThingValidations) // <== a proxy with validations
  25. })
  26. })

Installation

  1. ember install ember-cp-buffered-validations

Usage

[Longer description of how to use the addon in apps.]

Contributing

Installation

  • git clone <repository-url>
  • cd ember-cp-buffered-validations
  • yarn install

Linting

  • yarn lint:hbs
  • yarn lint:js
  • yarn lint:js --fix

Running tests

  • ember test – Runs the test suite on the current Ember version
  • ember test --server – Runs the test suite in “watch mode”
  • ember try:each – Runs the test suite against multiple Ember versions

Running the dummy application

For more information on using ember-cli, visit https://ember-cli.com/.

License

This project is licensed under the MIT License.