Skip to content

Conversation

@kurayama
Copy link
Member

@kurayama kurayama commented Sep 8, 2016

This PR adds the ability to specify the phones types allowed in the Phone assert.
With this we can, for example, only allow land line and mobile phones (avoid premium numbers).

if (!isArray(allowedTypes) || intersection(allowedTypes, keys(PhoneNumberType)).length !== allowedTypes.length) {
throw new Error('Phone types specified are not valid.');
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why .map but not Array.isArray?

}
});

it('should accept a valid phone in the e164 format', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test where a number belonging to an allowed type is accepted.

* The allowed phone number types.
*/

if (allowedTypes) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.keys?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants