How to use the ember-cp-validations/validators/messages.reopen function in ember-cp-validations

To help you get started, we’ve selected a few ember-cp-validations examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jasonmit / ember-i18n-cp-validations / addon / initialize.js View on Github external
export default function() {
  ValidatorsMessages.reopen({
    i18n: inject.service(),
    prefix: 'errors',
    _regex: /\{{(\w+)\}}/g,

    getDescriptionFor(attribute, options = {}) {
      const i18n = get(this, 'i18n');
      let key = `${get(this, 'prefix')}.description`;
      let foundCustom;

      if (!isEmpty(options.descriptionKey)) {
        key = options.descriptionKey;
        foundCustom = true;
      } else if (!isEmpty(options.description)) {
        return options.description;
      }