1

I am thinking of using dockyard validations in my project

I have options as to how to use the Validations-Mixin from dockyard

  • Approach 1 to have a BaseController which will mixin this Validations-Mixin and get the functionality in all controllers

  • Approach 2 use the Mixin directly.

Pros of 1 no need to import ember-validations in every file and mixin manually , and I get the functionality of validations in all the controllers.

Cons of 1 Validations might not be required in all the controllers , may be it's required only in 50% of the cases, also might reorder the way existing controllers add the mixins.

Pros of 2 Simple, only who need the functionality will import and use it.

Cons of 2 importing in each file where required and adding the mixin.

Patsy Issa
  • 11,113
  • 4
  • 55
  • 74
PCB
  • 638
  • 1
  • 11
  • 22

1 Answers1

1

I think you should use that mixin directly. Why?

Because there is no need to extend it in every controller in your app. Extending mixins is a way to obtain shared functionality between controllers that share that functionality. I am pretty sure that not every controller in your app needs validation.

From my experience I can say that only some percent of controllers use validations (it depends on the app, but it's just a rough mean value). Import the mixin where it's needed.

Kuba Niechciał
  • 974
  • 7
  • 9