How to use the ember-cp-validations/validators/messages.extend 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 / tests / dummy / app / validators / messages.js View on Github external
import ValidatorsMessage from 'ember-cp-validations/validators/messages';

export default ValidatorsMessage.extend({
  inclusion: "is not included in the list",
  exclusion: "is reserved",
  invalid: "is invalid",
  confirmation: "doesn't match {attribute}",
  accepted: "must be accepted",
  empty: "can't be empty",
  blank: "can't be blank",
  present: "must be blank",
  collection: "must be a collection",
  singular: "can't be a collection",
  tooLong: "is too long (maximum is {count} characters)",
  tooShort: "is too short (minimum is {count} characters)",
  before: "must be before {date}",
  after: "must be after {date}",
  wrongDateFormat: "must be in the format of {date}",
  wrongLength: "is the wrong length (should be {count} characters)",
github jasonmit / ember-i18n-cp-validations / addon / validators / messages.js View on Github external
function unwrap(input) {
  if (isSafeString(input)) {
    return input.toString();
  }

  return input;
}

function emitWarning(msg, meta, ENV) {
  if (!get(ENV, 'i18n.suppressWarnings')) {
    warn(msg, false, meta);
  }
}

export default ValidatorsMessages.extend({
  i18n: service(),
  _regex: /\{\{(\w+)\}\}|\{(\w+)\}/g,

  _prefix: computed('prefix', function() {
    const prefix = get(this, 'prefix');

    if (typeof prefix === 'string') {
      if (prefix.length) {
        return prefix + '.';
      }

      return prefix;
    }

    return 'errors.';
  }),