How to use the ember-changeset-validations/utils/with-defaults 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 / get-messages.js View on Github external
export default function getMessages(moduleMap = requirejs.entries, useCache = true) {
  let messagesModule = defaultMessages;

  if (useCache && isPresent(cachedRef)) {
    return cachedRef;
  }

  let moduleKey = emberArray(keys(moduleMap))
    .find((key) => key === moduleName);

  if (isPresent(moduleKey)) {
    // Merge the user specified messages with the defaults
    messagesModule = withDefaults(requireModule(moduleKey).default, messagesModule);
  }

  cachedRef = messagesModule;
  return messagesModule;
}
github poteto / ember-changeset-validations / addon / validators / length.js View on Github external
export default function validateLength(options = {}) {
  options = withDefaults(options, { useBetweenMessage: true });

  return (key, value) => {
    let result = validate('length', value, options, null, key);
    return (result === true) ? true : buildMessage(key, result);
  };
}
github poteto / ember-changeset-validations / addon / validators / number.js View on Github external
export default function validateNumber(options = {}) {
  options = withDefaults(options, { allowString: true, allowNone: false });

  if (options.allowBlank) {
    options.allowNone = true;
  }

  return (key, value) => {
    let result = validate('number', value, options, null, key);
    return (result === true) ? true : buildMessage(key, result);
  };
}