Skip to content

a glossary of universally intuitive time, date, and duration domain literals

License

Notifications You must be signed in to change notification settings

ehmpathy/domain-glossary-phone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

domain-glossary-phone

test publish

A glossary of intuitive, universally unambiguous phone definitions and useful procedures.

purpose

declare a universally unambiguous serialization format for phones

  • UniPhoneNumber = E.164
  • UniPhone = { number: UniPhoneNumber }

usecases

  • clarify the format a string should be in (const phoneNumber: UniPhoneNumber = '+13231110101')
  • cast date to universal format (const phoneNumber: UniPhoneNumber = asUniPhoneNumber('(323) 111-0101'))
  • narrow type of strings with runtime validation (if (!isUniPhoneNumber(input)) throw new Error('wrong format'))

install

npm install domain-glossary-phone

use

Phone

declare that a phone or phone.number must be in the universal format

const phone: UniPhone;
const phoneNumber: UniPhoneNumber;

assure that a phone number is in the universal format

const phone: UniPhone = { number: isUniPhoneNumber.assure('+13231110101') }

cast a phone number into the universal format

const phone: UniPhone = { number: asUniPhoneNumber('(323) 111-0101') }

About

a glossary of universally intuitive time, date, and duration domain literals

Resources

License

Stars

Watchers

Forks

Packages

No packages published