4.1.2 • Published 2 years ago

ember-validators v4.1.2

Weekly downloads
50,101
License
MIT
Repository
github
Last release
2 years ago

Ember Validators

Build Status npm version

A collection of EmberJS validators

ember install ember-validators

Helpful Links

Looking for help?

If it is a bug please open an issue on GitHub.

Usage

Validators can be individually imported and used as such

import validatePresence from 'ember-validators/presence';
import validateLength from 'ember-validators/length';

validatePresence('foo', { presence: true });
validateLength('foo', { min: 1 });

or via the validate method provided

import { validate } from 'ember-validators';

validate('presence', 'foo', { presence: true });
validate('length', 'foo', { min: 1 });

Validator Method Signature

Each validator has the following signature:

function (value, options, model, attribute) {}

Parameters:

  • value (Mixed):

    The value to validate

  • options (Object):

    A mutable object that holds validation specific options

  • model (Object):

    The model that is being validated

  • attribute (String):

    The attribute that is being validated

Returns:

  • Boolean

    true will be returned if the validation passed

  • Object

    Validation failed and a message should be built with the given attributes

    • type (String):

      The message type

    • value (Mixed):

      The value that was validated

    • context (Object):

      The error message context

    • message (String):

      The error message. If this is specified, use this string as the error message instead of building one.

4.1.0

2 years ago

4.0.1

2 years ago

4.1.2

2 years ago

4.1.1

2 years ago

4.0.0

3 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.0

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

8 years ago

0.1.0

8 years ago