How to use the ember-cp-validations/-private/ember-validator.extend 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 / inclusion.js View on Github external
*  validator('inclusion', {
 *    in: ['Admin'] // Input must be equal to 'Admin'
 *  })
 *  validator('inclusion', {
 *    range: [0, Infinity] // Input must be positive number
 *  })
 *  validator('inclusion', {
 *    range: [-Infinity, Infinity] // Input must be a number
 *  })
 *  ```
 *
 *  @class Inclusion
 *  @module Validators
 *  @extends Base
 */
export default EmberValidator.extend({
  _evType: 'inclusion'
});
github offirgolan / ember-cp-validations / addon / validators / presence.js View on Github external
*    presence: true,
 *    message: 'should not be empty'
 *  })
 *
 *  validator('presence', {
 *    presence: true,
 *    ignoreBlank: true,
 *    message: 'should not be empty or consist only of spaces'
 *  })
 *  ```
 *
 *  @class Presence
 *  @module Validators
 *  @extends Base
 */
export default EmberValidator.extend({
  _evType: 'presence',

  /**
   * Normalized options passed in.
   * ```js
   * validator('presence', true)
   * // Becomes
   * validator('presence', {
   *   presence: true
   * })
   * ```
   *
   * @method buildOptions
   * @param  {Object}     options
   * @param  {Object}     defaultOptions
   * @param  {Object}     globalOptions
github offirgolan / ember-cp-validations / addon / validators / number.js View on Github external
*
 *  ```javascript
 *  validator('number') // Simple check if the value is a number
 *  validator('number', {
 *    allowString: true,
 *    integer: true,
 *    gt: 5,
 *    lte: 100
 *  })
 *  ```
 *
 *  @class Number
 *  @module Validators
 *  @extends Base
 */
export default EmberValidator.extend({
  _evType: 'number'
});
github offirgolan / ember-cp-validations / addon / validators / exclusion.js View on Github external
*  ## Examples:
 *
 *  ```javascript
 *  validator('exclusion', {
 *    in: ['Admin', 'Super Admin']
 *  })
 *  validator('exclusion', {
 *    range: [0, 5] // Cannot be between 0 (inclusive) to 5 (inclusive)
 *  })
 *  ```
 *
 *  @class Exclusion
 *  @module Validators
 *  @extends Base
 */
export default EmberValidator.extend({
  _evType: 'exclusion'
});
github offirgolan / ember-cp-validations / addon / validators / collection.js View on Github external
*  ## Examples
 *
 *  ```javascript
 *  validator('collection', true)
 *  validator('collection', false)
 *  validator('collection', {
 *    collection: true,
 *    message: 'must be a collection'
 *  })
 *  ```
 *
 *  @class Collection
 *  @module Validators
 *  @extends Base
 */
const Collection = EmberValidator.extend({
  _evType: 'collection',

  /**
   * Normalized options passed in.
   * ```js
   * validator('collection', true)
   * // Becomes
   * validator('collection', {
   *   collection: true
   * })
   * ```
   *
   * @method buildOptions
   * @param  {Object}     options
   * @param  {Object}     defaultOptions
   * @param  {Object}     globalOptions
github offirgolan / ember-cp-validations / addon / validators / format.js View on Github external
*  If you do not want to use the predefined regex for a specific type, you can do something like this
 *
 *  ```javascript
 *  validator('format', {
 *    type: 'email',
 *    regex: /My Better Email Regexp/
 *  })
 *  ```
 *
 *  This allows you to still keep the email error message but with your own custom regex.
 *
 *  @class Format
 *  @module Validators
 *  @extends Base
 */
export default EmberValidator.extend({
  _evType: 'format',
  regularExpressions
});
github offirgolan / ember-cp-validations / addon / validators / confirmation.js View on Github external
*
 *  ```javascript
 *  email: validator('format', {
 *    type: 'email'
 *  })
 *  verifiedEmail: validator('confirmation', {
 *    on: 'email',
 *    message: 'Email addresses do not match'
 *  })
 *  ```
 *
 *  @class Confirmation
 *  @module Validators
 *  @extends Base
 */
const Confirmation = EmberValidator.extend({
  _evType: 'confirmation'
});

Confirmation.reopenClass({
  getDependentsFor(attribute, options) {
    let on = get(options, 'on');

    assert(
      `[validator:confirmation] [${attribute}] 'on' must be a string`,
      typeof on === 'string'
    );

    return on ? [`model.${on}`] : [];
  }
});
github offirgolan / ember-cp-validations / addon / validators / date.js View on Github external
*
 *  ```javascript
 *  validator('date', {
 *    after: 'now',
 *    before: '1/1/2020',
 *    precision: 'day',
 *    format: 'M/D/YYY',
 *    errorFormat: 'M/D/YYY'
 *  })
 *  ```
 *
 *  @class Date
 *  @module Validators
 *  @extends Base
 */
export default EmberValidator.extend({
  _evType: 'date'
});
github offirgolan / ember-cp-validations / addon / validators / ds-error.js View on Github external
*  <i aria-hidden="true" class="fa fa-hand-o-right"></i> [See All Options](#method_validate)
 *
 *  Creates a link between this library and Ember-Data's [DS.Errors](http://emberjs.com/api/data/classes/DS.Errors.html)
 *  to fetch the latest message for the given attribute.
 *
 *  ## Examples
 *
 *  ```javascript
 *  validator('ds-error')
 *  ```
 *
 *  @class DS Error
 *  @module Validators
 *  @extends Base
 */
const DSError = EmberValidator.extend({
  _evType: 'ds-error'
});

DSError.reopenClass({
  getDependentsFor(attribute) {
    let { path, key } = getPathAndKey(attribute);

    return [`model.${path}.${key}.[]`];
  }
});

export default DSError;
github offirgolan / ember-cp-validations / addon / validators / length.js View on Github external
*
 *  ```javascript
 *  validator('length', {
 *    is: 15
 *  })
 *  validator('length', {
 *    min: 5,
 *    max: 10
 *  })
 *  ```
 *
 *  @class Length
 *  @module Validators
 *  @extends Base
 */
export default EmberValidator.extend({
  _evType: 'length'
});