How to use the ember-validators/utils/unwrap-proxy function in ember-validators

To help you get started, we’ve selected a few ember-validators 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-validators / addon / presence.js View on Github external
export default function validatePresence(value, options, model, attribute) {
  let { presence, ignoreBlank } = getProperties(options, ['presence', 'ignoreBlank']);
  let v = unwrapProxy(value);
  let _isPresent = ignoreBlank ? isPresent(v) : !isEmpty(v);

  assert(`[validator:presence] [${attribute}] option 'presence' is required`, isPresent(presence));

  if (presence === true && !_isPresent) {
    return validationError('blank', value, options);
  }

  if (presence === false && _isPresent) {
    return validationError('present', value, options);
  }

  return true;
}