ember-intl / cp-validations

ember-intl support for ember-cp-validations
MIT License
10 stars 13 forks source link

Proposal: descriptionKey should also accept a function #14

Closed patric-eberle closed 7 years ago

patric-eberle commented 7 years ago

We create a dynamic form, where the fields and labels are delivered by the server. So we actually don't know the name of the field. If descriptionKey would accept a function, we could get the description name from the model.

const Validations = buildValidations({
  value: validator('presence', {
    presence: true,
    disabled: Ember.computed.readOnly('model.isDisabled.content'),
    descriptionKey(model) {
         return model.get('fieldName');
    }
  })
});
patric-eberle commented 7 years ago

I just discovered, that this issue is actually related to the description property of cp-validations itself. This would only make sense, if the translation key is dynamic, which is probably not a very common case.