Function
match (dependentKey, regexp) ComputedProperty public
Module:
@ember/object
Defined in packages/@ember/object/lib/computed/computed_macros.js:246
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import { match } from '@ember/object/computed'; import EmberObject from '@ember/object'; let User = EmberObject.extend({ hasValidEmail: 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 |