Re: Phone Number Validation Function

2017-09-11 Thread Stephen MacLean via use-livecode
Hi Bob,

Last year I released a sample library for base functions like this:

https://github.com/renegadesteve/rsIsValid 


You can use the LCS version, or build a widget library for your version of LC 9.

It does use RegEx, but you can Sean said, there are many ways to do what you 
are looking to do.

Since it seems that you are looking for consistency across you app, however you 
get there, it can be done in multiple ways. RegEx is a valid way to do.

As always, YMMV.

Best,

Steve MacLean

> On Sep 11, 2017, at 6:48 PM, Bob Sneidar via use-livecode 
>  wrote:
> 
> Thanks Sean, but reading through that article, I think it makes the arguement 
> for NOT using RegEx, seeing all the arguments back and forth about what is 
> wrong with each other's regex, and one guy pooh poohing all of them in favor 
> of a procedural approach. 
> 
> My goal is not to simply allow certain characters and numbers (I have a 
> function that does that already) of a given length, but to enforce data 
> consistency across my apps. That means that while certain numbers are 
> acceptably formatted phone numbers according to some international standard, 
> having +1 at the beginning for example, I don't necessarily want that. 
> Periods are valid delimiters, but I don't want that either. 
> 
> Now the google api looks promising, but if I have to tie it to a google 
> account and active internet connection, I will probably stick to rolling my 
> own. 
> 
> Bob S
> 
> 
>> On Sep 11, 2017, at 15:33 , Sean Cole (Pi) via use-livecode 
>>  wrote:
>> 
>> Read this:
>> https://stackoverflow.com/questions/123559/a-comprehensive-regex-for-phone-number-validation
>> 
>> You can then filter by these Regular Expressions (RegEx) really simply.
>> More importantly, it is one or two lines of code instead of 53.
>> 
>> Sean Cole
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Phone Number Validation Function

2017-09-11 Thread Bob Sneidar via use-livecode
Thanks Sean, but reading through that article, I think it makes the arguement 
for NOT using RegEx, seeing all the arguments back and forth about what is 
wrong with each other's regex, and one guy pooh poohing all of them in favor of 
a procedural approach. 

My goal is not to simply allow certain characters and numbers (I have a 
function that does that already) of a given length, but to enforce data 
consistency across my apps. That means that while certain numbers are 
acceptably formatted phone numbers according to some international standard, 
having +1 at the beginning for example, I don't necessarily want that. Periods 
are valid delimiters, but I don't want that either. 

Now the google api looks promising, but if I have to tie it to a google account 
and active internet connection, I will probably stick to rolling my own. 

Bob S


> On Sep 11, 2017, at 15:33 , Sean Cole (Pi) via use-livecode 
>  wrote:
> 
> Read this:
> https://stackoverflow.com/questions/123559/a-comprehensive-regex-for-phone-number-validation
> 
> You can then filter by these Regular Expressions (RegEx) really simply.
> More importantly, it is one or two lines of code instead of 53.
> 
> Sean Cole


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Phone Number Validation Function

2017-09-11 Thread Sean Cole (Pi) via use-livecode
There are currently 342 expressions on the regexlibrary:
http://www.regexlib.com/Search.aspx?k=phone=1

Some eliminate erroneous numbers too like those begining with 123 or 555
and so on.

Sean Cole
*Pi Digital Productions Ltd*
www.pidigital.co.uk
+44(1634)402193
+44(7702)116447
'Don't try to think outside the box. Just remember the truth: There is no
box!'
'For then you realise it is not the box you are trying to look outside of,
but it is yourself!'

eMail Ts & Cs <http://pidigital.co.uk/emailTCs.rtf>   Pi Digital
Productions Ltd is a UK registered limited company, no. 5255609

On 11 September 2017 at 23:33, Sean Cole (Pi) <s...@pidigital.co.uk> wrote:

> Read this:
> https://stackoverflow.com/questions/123559/a-
> comprehensive-regex-for-phone-number-validation
>
> You can then filter by these Regular Expressions (RegEx) really simply.
> More importantly, it is one or two lines of code instead of 53.
>
> Sean Cole
> *Pi Digital Productions Ltd*
>
> 'Don't try to think outside the box. Just remember the truth: There is no
> box!'
> 'For then you realise it is not the box you are trying to look outside of,
> but it is yourself!'
>
> eMail Ts & Cs <http://pidigital.co.uk/emailTCs.rtf>   Pi Digital
> Productions Ltd is a UK registered limited company, no. 5255609
>
> On 11 September 2017 at 20:04, JB via use-livecode <
> use-livecode@lists.runrev.com> wrote:
>
>> Thanks Bob.
>>
>> JB
>>
>>
>> > On Sep 11, 2017, at 11:20 AM, Bob Sneidar via use-livecode <
>> use-livecode@lists.runrev.com> wrote:
>> >
>> > Hi all.
>> >
>> > Since I needed to write one, I thought I would share this phone number
>> validation function. NOTE: it only works for phone numbers of the following
>> format:
>> >
>> > -- pure numbers
>> > nnn
>> > nn
>> >
>> > -- formatted numbers
>> > nnn-
>> > nnn-nnn-
>> > (nnn) nnn-
>> >
>> > It will also accept a space delimited extension so long as it begins
>> with x, ex or ext.
>> >
>> > Anyone who wants to massage it into shape for European or other phone
>> number formats can do so. The range checking is somewhat coarse, because I
>> had difficulty determining what the lowest and highest area code and prefix
>> can be, and also it may change in the future. Enjoy!
>> >
>> > Bob S
>> >
>> > function isPhoneNum pValue
>> >   /*
>> >   A phone number is a value whose raw numeric value is between 100
>> and 999, or 10 and
>> >   99, with an optional numeric value delimited by a space.
>> Additionally, the first and fifth characters
>> >   can be ( and ) respectively, in which case the 6th character must be
>> a space and the tenth character must be
>> >   a dash.
>> >   */
>> >   put pValue into tPhoneNumber -- preserve initial value
>> >   put last word of tPhoneNumber into tExtension
>> >
>> >   if first char of tExtension is "x" or char 1 to 3 of tExtension is
>> "ext" then
>> >  delete last word of tPhoneNumber -- lose the extension
>> >   else
>> >  put empty into tExtension -- it's not a valid extension
>> >   end if
>> >
>> >   -- range check
>> >   put cleanAscii(tPhoneNumber, "numbers") into tPhnValue
>> >
>> >   if tPhnValue > 999 then
>> >  if tPhnValue < 10 or tPhnValue > 99 then
>> > return false
>> >  end if
>> >   else
>> >  if tPhnValue < 100 then
>> > return false
>> >  end if
>> >   end if
>> >
>> >   -- pure numbers are OK
>> >   if tPhoneNumber = tPhnValue then return true
>> >
>> >   -- allowed characters
>> >   if length(tPhnValue) = 7 then
>> >  -- length must be 8 chars and char 4 must be a dash
>> >  if length(tPhoneNumber) <> 8 or char 4 of tPhoneNumber is not "-"
>> then
>> > return false
>> >  end if
>> >   else
>> >  -- length must be 14, 1st char must be (, 5th char must be ), 6th
>> char must be space and 10th char must be -
>> >  -- or else length must be 12, 4th char must be - and 8th char must
>> be -
>> >  if length(tPhoneNumber) <> 14 or length(tPhoneNumber) <> 12 then
>> > return false
>> >  end if
>> >
>> >  if length(tPhoneNum

Re: Phone Number Validation Function

2017-09-11 Thread Sean Cole (Pi) via use-livecode
Read this:
https://stackoverflow.com/questions/123559/a-comprehensive-regex-for-phone-number-validation

You can then filter by these Regular Expressions (RegEx) really simply.
More importantly, it is one or two lines of code instead of 53.

Sean Cole
*Pi Digital Productions Ltd*

'Don't try to think outside the box. Just remember the truth: There is no
box!'
'For then you realise it is not the box you are trying to look outside of,
but it is yourself!'

eMail Ts & Cs <http://pidigital.co.uk/emailTCs.rtf>   Pi Digital
Productions Ltd is a UK registered limited company, no. 5255609

On 11 September 2017 at 20:04, JB via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Thanks Bob.
>
> JB
>
>
> > On Sep 11, 2017, at 11:20 AM, Bob Sneidar via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > Hi all.
> >
> > Since I needed to write one, I thought I would share this phone number
> validation function. NOTE: it only works for phone numbers of the following
> format:
> >
> > -- pure numbers
> > nnn
> > nn
> >
> > -- formatted numbers
> > nnn-
> > nnn-nnn-
> > (nnn) nnn-
> >
> > It will also accept a space delimited extension so long as it begins
> with x, ex or ext.
> >
> > Anyone who wants to massage it into shape for European or other phone
> number formats can do so. The range checking is somewhat coarse, because I
> had difficulty determining what the lowest and highest area code and prefix
> can be, and also it may change in the future. Enjoy!
> >
> > Bob S
> >
> > function isPhoneNum pValue
> >   /*
> >   A phone number is a value whose raw numeric value is between 100
> and 999, or 10 and
> >   99, with an optional numeric value delimited by a space.
> Additionally, the first and fifth characters
> >   can be ( and ) respectively, in which case the 6th character must be a
> space and the tenth character must be
> >   a dash.
> >   */
> >   put pValue into tPhoneNumber -- preserve initial value
> >   put last word of tPhoneNumber into tExtension
> >
> >   if first char of tExtension is "x" or char 1 to 3 of tExtension is
> "ext" then
> >  delete last word of tPhoneNumber -- lose the extension
> >   else
> >  put empty into tExtension -- it's not a valid extension
> >   end if
> >
> >   -- range check
> >   put cleanAscii(tPhoneNumber, "numbers") into tPhnValue
> >
> >   if tPhnValue > 999 then
> >  if tPhnValue < 10 or tPhnValue > 99 then
> > return false
> >  end if
> >   else
> >  if tPhnValue < 100 then
> > return false
> >  end if
> >   end if
> >
> >   -- pure numbers are OK
> >   if tPhoneNumber = tPhnValue then return true
> >
> >   -- allowed characters
> >   if length(tPhnValue) = 7 then
> >  -- length must be 8 chars and char 4 must be a dash
> >  if length(tPhoneNumber) <> 8 or char 4 of tPhoneNumber is not "-"
> then
> > return false
> >  end if
> >   else
> >  -- length must be 14, 1st char must be (, 5th char must be ), 6th
> char must be space and 10th char must be -
> >  -- or else length must be 12, 4th char must be - and 8th char must
> be -
> >  if length(tPhoneNumber) <> 14 or length(tPhoneNumber) <> 12 then
> > return false
> >  end if
> >
> >  if length(tPhoneNumber) is 14 then
> > if char 1 of tPhoneNumber is not "(" or \
> >   char 5 of tPhoneNumber is not ")" or \
> >   char 6 of tPhoneNumber is not space or \
> >   char 10 of tPhoneNumber is not "-" then
> >return false
> > end if
> >  else
> > if char 4 of tPhoneNumber is not "-" or \
> >   char 8 of tPhoneNumber is not "-" then
> >return false
> > end if
> >  end if
> >   end if
> >   return true
> > end isPhoneNum
> > ___
> > use-livecode mailing list
> > use-livecode@lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Phone Number Validation Function

2017-09-11 Thread JB via use-livecode
Thanks Bob.

JB


> On Sep 11, 2017, at 11:20 AM, Bob Sneidar via use-livecode 
> <use-livecode@lists.runrev.com> wrote:
> 
> Hi all. 
> 
> Since I needed to write one, I thought I would share this phone number 
> validation function. NOTE: it only works for phone numbers of the following 
> format:
> 
> -- pure numbers
> nnn
> nn
> 
> -- formatted numbers
> nnn-
> nnn-nnn-
> (nnn) nnn-
> 
> It will also accept a space delimited extension so long as it begins with x, 
> ex or ext. 
> 
> Anyone who wants to massage it into shape for European or other phone number 
> formats can do so. The range checking is somewhat coarse, because I had 
> difficulty determining what the lowest and highest area code and prefix can 
> be, and also it may change in the future. Enjoy! 
> 
> Bob S
> 
> function isPhoneNum pValue
>   /*
>   A phone number is a value whose raw numeric value is between 100 and 
> 999, or 10 and 
>   99, with an optional numeric value delimited by a space. 
> Additionally, the first and fifth characters
>   can be ( and ) respectively, in which case the 6th character must be a 
> space and the tenth character must be 
>   a dash. 
>   */
>   put pValue into tPhoneNumber -- preserve initial value
>   put last word of tPhoneNumber into tExtension
> 
>   if first char of tExtension is "x" or char 1 to 3 of tExtension is "ext" 
> then 
>  delete last word of tPhoneNumber -- lose the extension
>   else 
>  put empty into tExtension -- it's not a valid extension
>   end if
> 
>   -- range check
>   put cleanAscii(tPhoneNumber, "numbers") into tPhnValue
> 
>   if tPhnValue > 999 then
>  if tPhnValue < 10 or tPhnValue > 99 then
> return false
>  end if
>   else
>  if tPhnValue < 100 then
> return false
>  end if
>   end if
> 
>   -- pure numbers are OK
>   if tPhoneNumber = tPhnValue then return true
> 
>   -- allowed characters
>   if length(tPhnValue) = 7 then
>  -- length must be 8 chars and char 4 must be a dash
>  if length(tPhoneNumber) <> 8 or char 4 of tPhoneNumber is not "-" then
> return false
>  end if
>   else
>  -- length must be 14, 1st char must be (, 5th char must be ), 6th char 
> must be space and 10th char must be -
>  -- or else length must be 12, 4th char must be - and 8th char must be -
>  if length(tPhoneNumber) <> 14 or length(tPhoneNumber) <> 12 then 
> return false
>  end if
> 
>  if length(tPhoneNumber) is 14 then
> if char 1 of tPhoneNumber is not "(" or \
>   char 5 of tPhoneNumber is not ")" or \
>   char 6 of tPhoneNumber is not space or \
>   char 10 of tPhoneNumber is not "-" then 
>return false
> end if
>  else
> if char 4 of tPhoneNumber is not "-" or \
>   char 8 of tPhoneNumber is not "-" then 
>return false
> end if
>  end if
>   end if
>   return true
> end isPhoneNum
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Phone Number Validation Function

2017-09-11 Thread Bob Sneidar via use-livecode
WHOOPS! Change this line to 
 if length(tPhoneNumber) <> 14 AND length(tPhoneNumber) <> 12 then 

> On Sep 11, 2017, at 11:20 , Bob Sneidar via use-livecode 
>  wrote:
> 
>  if length(tPhoneNumber) <> 14 or length(tPhoneNumber) <> 12 then 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Phone Number Validation Function

2017-09-11 Thread Bob Sneidar via use-livecode
Hi all. 

Since I needed to write one, I thought I would share this phone number 
validation function. NOTE: it only works for phone numbers of the following 
format:

-- pure numbers
nnn
nn

-- formatted numbers
nnn-
nnn-nnn-
(nnn) nnn-

It will also accept a space delimited extension so long as it begins with x, ex 
or ext. 

Anyone who wants to massage it into shape for European or other phone number 
formats can do so. The range checking is somewhat coarse, because I had 
difficulty determining what the lowest and highest area code and prefix can be, 
and also it may change in the future. Enjoy! 

Bob S

function isPhoneNum pValue
   /*
   A phone number is a value whose raw numeric value is between 100 and 
999, or 10 and 
   99, with an optional numeric value delimited by a space. 
Additionally, the first and fifth characters
   can be ( and ) respectively, in which case the 6th character must be a space 
and the tenth character must be 
   a dash. 
   */
   put pValue into tPhoneNumber -- preserve initial value
   put last word of tPhoneNumber into tExtension
   
   if first char of tExtension is "x" or char 1 to 3 of tExtension is "ext" 
then 
  delete last word of tPhoneNumber -- lose the extension
   else 
  put empty into tExtension -- it's not a valid extension
   end if
   
   -- range check
   put cleanAscii(tPhoneNumber, "numbers") into tPhnValue
   
   if tPhnValue > 999 then
  if tPhnValue < 10 or tPhnValue > 99 then
 return false
  end if
   else
  if tPhnValue < 100 then
 return false
  end if
   end if
   
   -- pure numbers are OK
   if tPhoneNumber = tPhnValue then return true
   
   -- allowed characters
   if length(tPhnValue) = 7 then
  -- length must be 8 chars and char 4 must be a dash
  if length(tPhoneNumber) <> 8 or char 4 of tPhoneNumber is not "-" then
 return false
  end if
   else
  -- length must be 14, 1st char must be (, 5th char must be ), 6th char 
must be space and 10th char must be -
  -- or else length must be 12, 4th char must be - and 8th char must be -
  if length(tPhoneNumber) <> 14 or length(tPhoneNumber) <> 12 then 
 return false
  end if
  
  if length(tPhoneNumber) is 14 then
 if char 1 of tPhoneNumber is not "(" or \
   char 5 of tPhoneNumber is not ")" or \
   char 6 of tPhoneNumber is not space or \
   char 10 of tPhoneNumber is not "-" then 
return false
 end if
  else
 if char 4 of tPhoneNumber is not "-" or \
   char 8 of tPhoneNumber is not "-" then 
return false
 end if
  end if
   end if
   return true
end isPhoneNum
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode