Ember.computed.match()

match (dependentKey, regexp) Ember.ComputedPropertypublic

Defined in packages/ember-runtime/lib/computed/computed_macros.js:216

A computed property which matches the original value for the dependent property against a given RegExp, returning true if the value matches the RegExp and false if it does not.

Example

let User = Ember.Object.extend({
  hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/)
});

let user = User.create({loggedIn: false});

user.get('hasValidEmail'); // false
user.set('email', '');
user.get('hasValidEmail'); // false
user.set('email', 'ember_hamster@example.com');
user.get('hasValidEmail'); // true

Parameters:

dependentKey String
regexp RegExp

Returns:

Ember.ComputedProperty
computed property which match the original value for property against a given RegExp
doc_EmberJs
2016-11-30 16:51:17
Comments
Leave a Comment

Please login to continue.