Function

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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { set } from '@ember/object';
import { match } from '@ember/object/computed';

class User {
  @match('email', /^.+@.+\..+$/) hasValidEmail;
}

let user = new User();

user.hasValidEmail; // false

set(user, 'email', '');
user.hasValidEmail; // false

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