ember-validators-octane
v3.0.1
Published
A collection of EmberJS validators
Downloads
3
Maintainers
Readme
Ember Validators Octane
A collection of EmberJS validators to support Octane edition. Forked from https://github.com/offirgolan/ember-validators
Installation
ember install ember-validators-octane
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-octane/presence';
import validateLength from 'ember-validators-octane/length';
validatePresence('foo', { presence: true });
validateLength('foo', { min: 1 });
or via the validate method provided
import { validate } from 'ember-validators-octane';
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 passedObject
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.