Sha256: b4c0f04450bc0c03d17795048c7285b9155c56c287199161f0cd08b5ba716d01
Contents?: true
Size: 642 Bytes
Versions: 295
Compression:
Stored size: 642 Bytes
Contents
class PhoneNumber { private value: string constructor(input: string) { let cleanedUp = input.replace(/(\)|\(|\s|\.|-)/g, "") if (cleanedUp.length === 11 && cleanedUp[0] === "1") { cleanedUp = cleanedUp.slice(1, 11) } this.value = cleanedUp } number(): string | undefined { if (this.value.length < 10 || this.value.length > 10 ) { return undefined } for (const each of this.value) { const result = parseInt(each, 10) if (isNaN(result)) {return undefined} } return this.value } } export default PhoneNumber
Version data entries
295 entries across 295 versions & 1 rubygems