Sha256: 84f4a616483b4aa7f6773a5658903f4f3df95e0846b82d16e54b023008d444ff
Contents?: true
Size: 443 Bytes
Versions: 155
Compression:
Stored size: 443 Bytes
Contents
export default class PhoneNumber { constructor(number) { this.rawNumber = number; } number() { if(/[a-zA-Z]/.test(this.rawNumber)) { return null; } return this._cleanedNumber(); } _cleanedNumber() { let num = this.rawNumber.replace(/\D/g,''); if (num.length === 10) { return num; } if (num.length === 11 && num[0] === '1') { return num.substr(1); } return null; } }
Version data entries
155 entries across 155 versions & 1 rubygems