How to use the ember-validators.validate 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 NYCPlanning / labs-zap-search / app / validators / presence-unless-value.js View on Github external
return (key, value, _oldValue, changes, content) => {
    if (target && (changes[target] || (changes[target] === undefined && content[target]))) {
      if ((changes[target] === targetValue) || (changes[target] === undefined && (content[target] === targetValue))) {
        return true;
      }
    }

    const result = validate('presence', value, options, null, key);

    if (typeof result === 'boolean' || typeof result === 'string') {
      return result;
    }
    // We flipped the meaning behind `present` and `blank` so switch the two
    if (result.type === 'present') {
      result.type = 'blank';
    } else if (result.type === 'blank') {
      result.type = 'present';
    }

    return buildMessage(key, result);
  };
}
github poteto / ember-changeset-validations / addon / validators / presence.js View on Github external
return (key, value, _oldValue, changes, content) => {
    if (targets && !targets.some((target) => changes[target] || (changes[target] === undefined && content[target]))) {
      return true;
    }

    let result = validate('presence', value, options, null, key);

    if (typeof result === 'boolean' || typeof result === 'string') {
      return result;
    } else {
      // We flipped the meaning behind `present` and `blank` so switch the two
      if (result.type === 'present') {
        result.type = 'blank';
      } else if (result.type === 'blank') {
        result.type = 'present';
      }

      return buildMessage(key, result);
    }
  };
}
github poteto / ember-changeset-validations / addon / validators / confirmation.js View on Github external
return (key, newValue, _oldValue, changes/*, _content*/) => {
    let result = validate('confirmation', newValue, options, changes, key);
    return (result === true) ? true : buildMessage(key, result);
  };
}
github offirgolan / ember-cp-validations / addon / -private / ember-validator.js View on Github external
validate() {
    let result = _validate(this.get('_evType'), ...arguments);

    if (result && typeof result === 'object') {
      return result.message
        ? result.message
        : this.createErrorMessage(result.type, result.value, result.context);
    }

    return result;
  }
});
github poteto / ember-changeset-validations / addon / validators / exclusion.js View on Github external
return (key, value) => {
    let result = validate('exclusion', value, options, null, key);
    return (result === true) ? true : buildMessage(key, result);
  };
}
github poteto / ember-changeset-validations / addon / validators / inclusion.js View on Github external
return (key, value) => {
    let result = validate('inclusion', value, options, null, key);
    return (result === true) ? true : buildMessage(key, result);
  };
}
github poteto / ember-changeset-validations / addon / validators / length.js View on Github external
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 / format.js View on Github external
return (key, value) => {
    if (!hasOptions) {
      return true;
    }

    let result = validate('format', value, options, null, key);
    return (result === true) ? true : buildMessage(key, result);
  };
}
github poteto / ember-changeset-validations / addon / validators / number.js View on Github external
return (key, value) => {
    let result = validate('number', value, options, null, key);
    return (result === true) ? true : buildMessage(key, result);
  };
}