Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/script/countries/IND.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Phone = require('../Phone')
PhoneNumber = require('../PhoneNumber')

# For more info check:
# http://www.howtocallabroad.com/bolivia/
class India
constructor: ->
@countryName = "India"
@countryNameAbbr = "IND"
@countryCode = '91'
@regex = /^(?:(?:(?:\+|)591)|)(?:0|)[23467]\d{7}$/
@optionalTrunkPrefix = '0'
@nationalNumberSeparator = ' '
@nationalDestinationCode = ['6', '7', '8', '9', '0']

specialRules: (withoutCountryCode, withoutNDC, ndc) =>
phone = new PhoneNumber(@countryNameAbbr, @countryCode, ndc, withoutNDC)

if withoutNDC.length is 10
if ndc in ['0']
phone.isMobile = true
phone.nationalDestinationCode = ''
phone.number = withoutCountryCode
else
phone.isMobile = false
return phone

splitNumber: (number) =>
if number.length is 10
return Phone.compact number.split(/(\d{4})(\d{6})/)
else if number.length is 13
return Phone.compact number.split(/(\d{3})(\d{4})(\d{6})/)

return [number]

# register
india = new India()
Phone.countries['91'] = inida

# exports
module.exports = india