ember / 2.18.0 / functions / @ember / object / computed / match.html /

Function

match (dependentKey, regexp) ComputedProperty public

Module: @ember/object
import { match } from '@ember/object/computed';
dependentKey
String
regexp
RegExp
returns
ComputedProperty
computed property which match the original value for property against a given RegExp

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', '[email protected]');
user.get('hasValidEmail'); // true

© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/2.18/functions/@ember%2Fobject%2Fcomputed/match