How to use the ember-changeset-validations/utils/get-messages function in ember-changeset-validations

To help you get started, we’ve selected a few ember-changeset-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 poteto / ember-changeset-validations / addon / utils / validation-errors.js View on Github external
export default function buildMessage(key, result) {
  let returnsRaw = getWithDefault(config, 'changeset-validations.rawOutput', false);
  let messages = getMessages();

  let description = messages.getDescriptionFor(key);

  if (result.message) {
    return result.message;
  }

  let { type, value, context = {} } = result;

  if (context.message) {
    let message = context.message;

    if (typeOf(message) === 'function') {
      let builtMessage = message(key, type, value, context);
      assert('Custom message function must return a string', typeOf(builtMessage) === 'string');