Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support allowing specific phone types #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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).

throw new Error('Phone types specified are not valid.');
}

this.allowedTypes = allowedTypes.map(type => PhoneNumberType[type]);
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?

e.show().assert.should.equal('Phone');
}
});

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.

*/

if (allowedTypes) {
if (!isArray(allowedTypes) || intersection(allowedTypes, keys(PhoneNumberType)).length !== allowedTypes.length) {
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