@eflexsystems/ember-tracked-validations
Version:
Ember computed property based validation library
32 lines (29 loc) • 684 B
JavaScript
import Base from '@eflexsystems/ember-tracked-validations/validators/base';
/**
* Accepts a custom `validate` function.
*
* ## Examples
*
* ```javascript
* validator('inline', {
* username: 'offirgolan',
* validate(value, options, model, attribute) {
* return value === options.username ?
* true :
* `Username must be ${options.username}`;
* }
* });
* ```
*
* @class Inline
* @module Validators
* @extends Base
*/
export default class ValidatorsInline extends Base {
validate() {
return this.options.validate.call(this, ...arguments);
}
static create(props) {
return new ValidatorsInline(props);
}
}