How to use the ember-cp-validations/utils/utils.unwrapString 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 offirgolan / ember-cp-validations / addon / validators / base.js View on Github external
createErrorMessage(type, value, options = {}) {
    let messages = this.get('errorMessages');
    let message = unwrapString(get(options, 'message'));

    set(
      options,
      'description',
      messages.getDescriptionFor(get(this, 'attribute'), options)
    );

    if (message) {
      if (typeof message === 'string') {
        message = messages.formatMessage(message, options);
      } else if (typeof message === 'function') {
        message = message.apply(this, arguments);
        message = isNone(message)
          ? messages.getMessageFor(type, options)
          : messages.formatMessage(message, options);
      }