Re: Validating GB telephone numbers in Django forms.

2012-09-11 Thread g1smd.1

Brad Pitcher stepped in and made the various code conversions.

There's just a few more changes and updates to go and the module will be 
complete.


On Wednesday, September 5, 2012 11:05:45 PM UTC, g1smd.1 wrote:
>
>
> The GB number plan is quite complicated, with a variety of number lengths 
> and formats.
> Some of it is detailed here:
> http://www.aa-asterisk.org.uk/index.php/Number_format
>
> I already compiled all the RegEx patterns that are needed. Some are listed 
> here:
>
> http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_UK_Telephone_Numbers
>
> I've already started the process of translating a fully working PHP 
> routine (that I wrote from scratch) into python. There will be syntax 
> errors in the python version as I don't understand all that much of the 
> python language.
>
> The python functionality so far  
> https://github.com/django/django/pull/324/files
> or
>
> https://github.com/g1smd/django/blob/master/django/contrib/localflavor/gb/forms.py
>
> The code using an array is probably not quite right, and I guess it would 
> be better to return error messages instead of "false" in some places.
>
> However, I'd guess that someone who knows what they were doing could get 
> it working in an hour or two.
>
>
>
> On Wednesday, September 5, 2012 6:24:42 PM UTC, Amyth wrote:
>>
>> To be frank, I am not really familiar with all possibilities of GB phone 
>> numbers, if you could throw some light on this, I might be able to help ya.
>>
>> On Wed, Sep 5, 2012 at 5:59 PM, g1smd.1  wrote:
>>
>>>
>>> Thanks for the reply and information.
>>>
>>>
>>> The jQuery validation routines for GB telephone numbers contain 
>>> significant errors and shortcomings. I already posted some patches 
>>> correcting many of those problems at least a month ago, but they haven't 
>>> been reviewed yet.
>>>
>>>
>>> The new Python/django telephone number validation code I am proposing 
>>> here is far more comprehensive and has much more detailed range and length 
>>> checking. Similar code already works fine in PHP and Java elsewhere, but I 
>>> am having trouble converting it all to Python. 
>>>
>>> I have added some Python logic and code to the initial RegEx patterns 
>>> that I posted yesterday, but I now need help to finish it off and get it 
>>> working. I am not at all familiar with the Python syntax and the manual is 
>>> somewhat terse and obtuse.
>>>
>>> I had a problem with GitHub this morning, so the pull request is now at 
>>> https://github.com/django/django/pull/324
>>>
>>> The code so far, can be found at: 
>>> https://github.com/g1smd/django/blob/master/django/contrib/localflavor/gb/forms.py
>>>
>>> I'm guessing that someone proficient in Python could finish it off in a 
>>> couple of hours or less.
>>>
>>> Any volunteers?
>>>
>>>
>>>
>>>
>>> On Wednesday, September 5, 2012 7:02:09 AM UTC, Amyth wrote:

 you can alternatively use jquery to validate the field, i do not have 
 the link handy as m on my phone right now but google validation engine, it 
 is one of the most powerful jquery validation library which also has 
 builtin method of validating uk phone numbers.
 On Sep 4, 2012 5:00 AM, "g1smd.1"  wrote:

>  I see that there are routines for validating telephone numbers in 
> forms in Django for several countries.
>
> The code for that can usually be found in the forms.py file located in 
> the various country folders here:
> https://github.com/django/**django/tree/master/django/**
> contrib/localflavor
>  
>
> So far, there is nothing for GB numbers, here:
> https://github.com/django/**django/tree/master/django/**
> contrib/localflavor/gb
>
> I've written a bunch of RegEx patterns to get this functionality 
> started. The patterns are 100% fully tested. All that's needed is a few 
> lines of python logic to string them together. The details can be found 
> at:
> https://github.com/django/**django/pull/316/files
>
> My python foo is almost zero. Anyone care to have a go at getting this 
> to work?
>
> RegEx 1 checks the user entered something that looks like a GB 
> telephone number:
> 020  3000  
> 02075  567  234
> 0114  223  4567
> 01145  345  567
> +44  1213  456  789
> 00  44  (0)  1697  73555
> 011  44  11  4890  2345
> and several other formats, without worrying if the format is correct 
> for this particular number (but read on). It allows for national or 
> international format, even for two common international dial prefixes. 
> What 
> is most important is that the user enters the right number of digits. 
> Don't 
> constrain the user to use a particular format for entr

Re: Validating GB telephone numbers in Django forms.

2012-09-05 Thread g1smd.1

The GB number plan is quite complicated, with a variety of number lengths 
and formats.
Some of it is detailed here:
http://www.aa-asterisk.org.uk/index.php/Number_format

I already compiled all the RegEx patterns that are needed. Some are listed 
here:
http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_UK_Telephone_Numbers

I've already started the process of translating a fully working PHP routine 
(that I wrote from scratch) into python. There will be syntax errors in the 
python version as I don't understand all that much of the python language.

The python functionality so far  
https://github.com/django/django/pull/324/files
or
https://github.com/g1smd/django/blob/master/django/contrib/localflavor/gb/forms.py

The code using an array is probably not quite right, and I guess it would 
be better to return error messages instead of "false" in some places.

However, I'd guess that someone who knows what they were doing could get it 
working in an hour or two.



On Wednesday, September 5, 2012 6:24:42 PM UTC, Amyth wrote:
>
> To be frank, I am not really familiar with all possibilities of GB phone 
> numbers, if you could throw some light on this, I might be able to help ya.
>
> On Wed, Sep 5, 2012 at 5:59 PM, g1smd.1  >wrote:
>
>>
>> Thanks for the reply and information.
>>
>>
>> The jQuery validation routines for GB telephone numbers contain 
>> significant errors and shortcomings. I already posted some patches 
>> correcting many of those problems at least a month ago, but they haven't 
>> been reviewed yet.
>>
>>
>> The new Python/django telephone number validation code I am proposing 
>> here is far more comprehensive and has much more detailed range and length 
>> checking. Similar code already works fine in PHP and Java elsewhere, but I 
>> am having trouble converting it all to Python. 
>>
>> I have added some Python logic and code to the initial RegEx patterns 
>> that I posted yesterday, but I now need help to finish it off and get it 
>> working. I am not at all familiar with the Python syntax and the manual is 
>> somewhat terse and obtuse.
>>
>> I had a problem with GitHub this morning, so the pull request is now at 
>> https://github.com/django/django/pull/324
>>
>> The code so far, can be found at: 
>> https://github.com/g1smd/django/blob/master/django/contrib/localflavor/gb/forms.py
>>
>> I'm guessing that someone proficient in Python could finish it off in a 
>> couple of hours or less.
>>
>> Any volunteers?
>>
>>
>>
>>
>> On Wednesday, September 5, 2012 7:02:09 AM UTC, Amyth wrote:
>>>
>>> you can alternatively use jquery to validate the field, i do not have 
>>> the link handy as m on my phone right now but google validation engine, it 
>>> is one of the most powerful jquery validation library which also has 
>>> builtin method of validating uk phone numbers.
>>> On Sep 4, 2012 5:00 AM, "g1smd.1"  wrote:
>>>
  I see that there are routines for validating telephone numbers in 
 forms in Django for several countries.

 The code for that can usually be found in the forms.py file located in 
 the various country folders here:
 https://github.com/django/**django/tree/master/django/**
 contrib/localflavor
  

 So far, there is nothing for GB numbers, here:
 https://github.com/django/**django/tree/master/django/**
 contrib/localflavor/gb

 I've written a bunch of RegEx patterns to get this functionality 
 started. The patterns are 100% fully tested. All that's needed is a few 
 lines of python logic to string them together. The details can be found at:
 https://github.com/django/**django/pull/316/files

 My python foo is almost zero. Anyone care to have a go at getting this 
 to work?

 RegEx 1 checks the user entered something that looks like a GB 
 telephone number:
 020  3000  
 02075  567  234
 0114  223  4567
 01145  345  567
 +44  1213  456  789
 00  44  (0)  1697  73555
 011  44  11  4890  2345
 and several other formats, without worrying if the format is correct 
 for this particular number (but read on). It allows for national or 
 international format, even for two common international dial prefixes. 
 What 
 is most important is that the user enters the right number of digits. 
 Don't 
 constrain the user to use a particular format for entry.
 "Be lenient in what you accept, be strict in what you send." (Postel's 
 Law)

 RegEx 2 extracts the NSN part of the number in $3, with "44" or NULL in 
 $2 (so you know if international or national format was used on input), 
 and 
 any extension in $4. Store $2 and $4 for later. Send $3 on to RegEx 3.

 RegEx 3 tests t

Re: Validating GB telephone numbers in Django forms.

2012-09-05 Thread Amyth Arora
To be frank , i am not really familiar with all possibilities of GB phone
numbers, if you could throw some light on this, i might be able to help ya.

On Wed, Sep 5, 2012 at 5:59 PM, g1smd.1  wrote:

>
> Thanks for the reply and information.
>
>
> The jQuery validation routines for GB telephone numbers contain
> significant errors and shortcomings. I already posted some patches
> correcting many of those problems at least a month ago, but they haven't
> been reviewed yet.
>
>
> The new Python/django telephone number validation code I am proposing here
> is far more comprehensive and has much more detailed range and length
> checking. Similar code already works fine in PHP and Java elsewhere, but I
> am having trouble converting it all to Python.
>
> I have added some Python logic and code to the initial RegEx patterns that
> I posted yesterday, but I now need help to finish it off and get it
> working. I am not at all familiar with the Python syntax and the manual is
> somewhat terse and obtuse.
>
> I had a problem with GitHub this morning, so the pull request is now at
> https://github.com/django/django/pull/324
>
> The code so far, can be found at:
> https://github.com/g1smd/django/blob/master/django/contrib/localflavor/gb/forms.py
>
> I'm guessing that someone proficient in Python could finish it off in a
> couple of hours or less.
>
> Any volunteers?
>
>
>
>
> On Wednesday, September 5, 2012 7:02:09 AM UTC, Amyth wrote:
>>
>> you can alternatively use jquery to validate the field, i do not have the
>> link handy as m on my phone right now but google validation engine, it is
>> one of the most powerful jquery validation library which also has builtin
>> method of validating uk phone numbers.
>> On Sep 4, 2012 5:00 AM, "g1smd.1"  wrote:
>>
>>> I see that there are routines for validating telephone numbers in forms
>>> in Django for several countries.
>>>
>>> The code for that can usually be found in the forms.py file located in
>>> the various country folders here:
>>> https://github.com/django/**django/tree/master/django/**
>>> contrib/localflavor
>>>
>>> So far, there is nothing for GB numbers, here:
>>> https://github.com/django/**django/tree/master/django/**
>>> contrib/localflavor/gb
>>>
>>> I've written a bunch of RegEx patterns to get this functionality
>>> started. The patterns are 100% fully tested. All that's needed is a few
>>> lines of python logic to string them together. The details can be found at:
>>> https://github.com/django/**django/pull/316/files
>>>
>>> My python foo is almost zero. Anyone care to have a go at getting this
>>> to work?
>>>
>>> RegEx 1 checks the user entered something that looks like a GB telephone
>>> number:
>>> 020  3000  
>>> 02075  567  234
>>> 0114  223  4567
>>> 01145  345  567
>>> +44  1213  456  789
>>> 00  44  (0)  1697  73555
>>> 011  44  11  4890  2345
>>> and several other formats, without worrying if the format is correct for
>>> this particular number (but read on). It allows for national or
>>> international format, even for two common international dial prefixes. What
>>> is most important is that the user enters the right number of digits. Don't
>>> constrain the user to use a particular format for entry.
>>> "Be lenient in what you accept, be strict in what you send." (Postel's
>>> Law)
>>>
>>> RegEx 2 extracts the NSN part of the number in $3, with "44" or NULL in
>>> $2 (so you know if international or national format was used on input), and
>>> any extension in $4. Store $2 and $4 for later. Send $3 on to RegEx 3.
>>>
>>> RegEx 3 tests the NSN part of the number is in a valid range and has the
>>> right number of digits for that range (GB numbers can be 9 or 10 digits
>>> long). This RegEx pattern is very detailed. You can say that a number is
>>> possible or is invalid with this RegEx.
>>>
>>> RegEx Group 4. Here, there's a bunch of RegEx patterns that specify how
>>> a GB number should be formatted, detailed by number length and initial
>>> digits. These rules cover all GB numbers.
>>>
>>> The last bit is to add the 0 or +44 back on, and append the original
>>> extension number (if present) and present it back to the user.
>>>
>>> 020  3000   => Valid: 020  3000  
>>> 02075  567  234 => Valid: 020  7556  7234
>>> 0114  223  4567 => Valid: 0114  223  4567
>>> 01145  345  567 => Valid: 0114  534  5567
>>> +44  1213  456  789 => Valid: +44  121  345  6789
>>> 00  44  (0)  1697  73555 => Valid: +44  16977  3555
>>> 011  44  11  4890  2345 => Valid: +44  114  890  2345
>>> 0623 111 3456 => NOT VALID
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/django-users/-/**h0iG7nJrXikJ

Re: Validating GB telephone numbers in Django forms.

2012-09-05 Thread g1smd.1

Thanks for the reply and information.


The jQuery validation routines for GB telephone numbers contain significant 
errors and shortcomings. I already posted some patches correcting many of 
those problems at least a month ago, but they haven't been reviewed yet.


The new Python/django telephone number validation code I am proposing here 
is far more comprehensive and has much more detailed range and length 
checking. Similar code already works fine in PHP and Java elsewhere, but I 
am having trouble converting it all to Python. 

I have added some Python logic and code to the initial RegEx patterns that 
I posted yesterday, but I now need help to finish it off and get it 
working. I am not at all familiar with the Python syntax and the manual is 
somewhat terse and obtuse.

I had a problem with GitHub this morning, so the pull request is now at 
https://github.com/django/django/pull/324

The code so far, can be found at: 
https://github.com/g1smd/django/blob/master/django/contrib/localflavor/gb/forms.py

I'm guessing that someone proficient in Python could finish it off in a 
couple of hours or less.

Any volunteers?




On Wednesday, September 5, 2012 7:02:09 AM UTC, Amyth wrote:
>
> you can alternatively use jquery to validate the field, i do not have the 
> link handy as m on my phone right now but google validation engine, it is 
> one of the most powerful jquery validation library which also has builtin 
> method of validating uk phone numbers.
> On Sep 4, 2012 5:00 AM, "g1smd.1" > 
> wrote:
>
>> I see that there are routines for validating telephone numbers in forms 
>> in Django for several countries.
>>
>> The code for that can usually be found in the forms.py file located in 
>> the various country folders here:
>> https://github.com/django/django/tree/master/django/contrib/localflavor 
>>
>> So far, there is nothing for GB numbers, here:
>> https://github.com/django/django/tree/master/django/contrib/localflavor/gb
>>
>> I've written a bunch of RegEx patterns to get this functionality started. 
>> The patterns are 100% fully tested. All that's needed is a few lines of 
>> python logic to string them together. The details can be found at:
>> https://github.com/django/django/pull/316/files
>>
>> My python foo is almost zero. Anyone care to have a go at getting this to 
>> work?
>>
>> RegEx 1 checks the user entered something that looks like a GB telephone 
>> number:
>> 020  3000  
>> 02075  567  234
>> 0114  223  4567
>> 01145  345  567
>> +44  1213  456  789
>> 00  44  (0)  1697  73555
>> 011  44  11  4890  2345
>> and several other formats, without worrying if the format is correct for 
>> this particular number (but read on). It allows for national or 
>> international format, even for two common international dial prefixes. What 
>> is most important is that the user enters the right number of digits. Don't 
>> constrain the user to use a particular format for entry.
>> "Be lenient in what you accept, be strict in what you send." (Postel's 
>> Law)
>>
>> RegEx 2 extracts the NSN part of the number in $3, with "44" or NULL in 
>> $2 (so you know if international or national format was used on input), and 
>> any extension in $4. Store $2 and $4 for later. Send $3 on to RegEx 3.
>>
>> RegEx 3 tests the NSN part of the number is in a valid range and has the 
>> right number of digits for that range (GB numbers can be 9 or 10 digits 
>> long). This RegEx pattern is very detailed. You can say that a number is 
>> possible or is invalid with this RegEx.
>>
>> RegEx Group 4. Here, there's a bunch of RegEx patterns that specify how a 
>> GB number should be formatted, detailed by number length and initial 
>> digits. These rules cover all GB numbers.
>>
>> The last bit is to add the 0 or +44 back on, and append the original 
>> extension number (if present) and present it back to the user.
>>
>> 020  3000   => Valid: 020  3000  
>> 02075  567  234 => Valid: 020  7556  7234
>> 0114  223  4567 => Valid: 0114  223  4567
>> 01145  345  567 => Valid: 0114  534  5567
>> +44  1213  456  789 => Valid: +44  121  345  6789
>> 00  44  (0)  1697  73555 => Valid: +44  16977  3555
>> 011  44  11  4890  2345 => Valid: +44  114  890  2345
>> 0623 111 3456 => NOT VALID
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/h0iG7nJrXikJ.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>

 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Zohb6P8AsaIJ.
To post to this group, send email to django-users@goo

Re: Validating GB telephone numbers in Django forms.

2012-09-05 Thread Amyth Arora
you can alternatively use jquery to validate the field, i do not have the
link handy as m on my phone right now but google validation engine, it is
one of the most powerful jquery validation library which also has builtin
method of validating uk phone numbers.
On Sep 4, 2012 5:00 AM, "g1smd.1"  wrote:

> I see that there are routines for validating telephone numbers in forms in
> Django for several countries.
>
> The code for that can usually be found in the forms.py file located in the
> various country folders here:
> https://github.com/django/django/tree/master/django/contrib/localflavor
>
> So far, there is nothing for GB numbers, here:
> https://github.com/django/django/tree/master/django/contrib/localflavor/gb
>
> I've written a bunch of RegEx patterns to get this functionality started.
> The patterns are 100% fully tested. All that's needed is a few lines of
> python logic to string them together. The details can be found at:
> https://github.com/django/django/pull/316/files
>
> My python foo is almost zero. Anyone care to have a go at getting this to
> work?
>
> RegEx 1 checks the user entered something that looks like a GB telephone
> number:
> 020  3000  
> 02075  567  234
> 0114  223  4567
> 01145  345  567
> +44  1213  456  789
> 00  44  (0)  1697  73555
> 011  44  11  4890  2345
> and several other formats, without worrying if the format is correct for
> this particular number (but read on). It allows for national or
> international format, even for two common international dial prefixes. What
> is most important is that the user enters the right number of digits. Don't
> constrain the user to use a particular format for entry.
> "Be lenient in what you accept, be strict in what you send." (Postel's Law)
>
> RegEx 2 extracts the NSN part of the number in $3, with "44" or NULL in $2
> (so you know if international or national format was used on input), and
> any extension in $4. Store $2 and $4 for later. Send $3 on to RegEx 3.
>
> RegEx 3 tests the NSN part of the number is in a valid range and has the
> right number of digits for that range (GB numbers can be 9 or 10 digits
> long). This RegEx pattern is very detailed. You can say that a number is
> possible or is invalid with this RegEx.
>
> RegEx Group 4. Here, there's a bunch of RegEx patterns that specify how a
> GB number should be formatted, detailed by number length and initial
> digits. These rules cover all GB numbers.
>
> The last bit is to add the 0 or +44 back on, and append the original
> extension number (if present) and present it back to the user.
>
> 020  3000   => Valid: 020  3000  
> 02075  567  234 => Valid: 020  7556  7234
> 0114  223  4567 => Valid: 0114  223  4567
> 01145  345  567 => Valid: 0114  534  5567
> +44  1213  456  789 => Valid: +44  121  345  6789
> 00  44  (0)  1697  73555 => Valid: +44  16977  3555
> 011  44  11  4890  2345 => Valid: +44  114  890  2345
> 0623 111 3456 => NOT VALID
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/h0iG7nJrXikJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Validating GB telephone numbers in Django forms.

2012-09-04 Thread g1smd.1
On Monday, September 3, 2012 8:10:46 PM UTC, g1smd.1 wrote:
>
> I see that there are routines for validating telephone numbers in forms in 
> Django for several countries.
>
> The code for that can usually be found in the forms.py file located in the 
> various country folders here:
> https://github.com/django/django/tree/master/django/contrib/localflavor 
>
> So far, there is nothing for GB numbers, here:
> https://github.com/django/django/tree/master/django/contrib/localflavor/gb
>
> I've written a bunch of RegEx patterns to get this functionality started. 
> The patterns are 100% fully tested. All that's needed is a few lines of 
> python logic to string them together. The details can be found at:
> https://github.com/django/django/pull/316/files
>
> My python foo is almost zero. Anyone care to have a go at getting this to 
> work?
>
> RegEx 1 checks the user entered something that looks like a GB telephone 
> number:
> 020  3000  
> 02075  567  234
> 0114  223  4567
> 01145  345  567
> +44  1213  456  789
> 00  44  (0)  1697  73555
> 011  44  11  4890  2345
> and several other formats, without worrying if the format is correct for 
> this particular number (but read on). It allows for national or 
> international format, even for two common international dial prefixes. What 
> is most important is that the user enters the right number of digits. Don't 
> constrain the user to use a particular format for entry.
> "Be lenient in what you accept, be strict in what you send." (Postel's Law)
>
> RegEx 2 extracts the NSN part of the number in $3, with "44" or NULL in $2 
> (so you know if international or national format was used on input), and 
> any extension in $4. Store $2 and $4 for later. Send $3 on to RegEx 3.
>
> RegEx 3 tests the NSN part of the number is in a valid range and has the 
> right number of digits for that range (GB numbers can be 9 or 10 digits 
> long). This RegEx pattern is very detailed. You can say that a number is 
> possible or is invalid with this RegEx.
>
> RegEx Group 4. Here, there's a bunch of RegEx patterns that specify how a 
> GB number should be formatted, detailed by number length and initial 
> digits. These rules cover all GB numbers.
>
> The last bit is to add the 0 or +44 back on, and append the original 
> extension number (if present) and present it back to the user.
>
> 020  3000   => Valid: 020  3000  
> 02075  567  234 => Valid: 020  7556  7234
> 0114  223  4567 => Valid: 0114  223  4567
> 01145  345  567 => Valid: 0114  534  5567
> +44  1213  456  789 => Valid: +44  121  345  6789
> 00  44  (0)  1697  73555 => Valid: +44  16977  3555
> 011  44  11  4890  2345 => Valid: +44  114  890  2345
> 0623 111 3456 => NOT VALID
>
>
>

This is now also filed as ticket #18903 at 
https://code.djangoproject.com/ticket/18903




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/K9lpBp_pfUMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Validating GB telephone numbers in Django forms.

2012-09-03 Thread g1smd.1
I see that there are routines for validating telephone numbers in forms in 
Django for several countries.

The code for that can usually be found in the forms.py file located in the 
various country folders here:
https://github.com/django/django/tree/master/django/contrib/localflavor 

So far, there is nothing for GB numbers, here:
https://github.com/django/django/tree/master/django/contrib/localflavor/gb

I've written a bunch of RegEx patterns to get this functionality started. 
The patterns are 100% fully tested. All that's needed is a few lines of 
python logic to string them together. The details can be found at:
https://github.com/django/django/pull/316/files

My python foo is almost zero. Anyone care to have a go at getting this to 
work?

RegEx 1 checks the user entered something that looks like a GB telephone 
number:
020  3000  
02075  567  234
0114  223  4567
01145  345  567
+44  1213  456  789
00  44  (0)  1697  73555
011  44  11  4890  2345
and several other formats, without worrying if the format is correct for 
this particular number (but read on). It allows for national or 
international format, even for two common international dial prefixes. What 
is most important is that the user enters the right number of digits. Don't 
constrain the user to use a particular format for entry.
"Be lenient in what you accept, be strict in what you send." (Postel's Law)

RegEx 2 extracts the NSN part of the number in $3, with "44" or NULL in $2 
(so you know if international or national format was used on input), and 
any extension in $4. Store $2 and $4 for later. Send $3 on to RegEx 3.

RegEx 3 tests the NSN part of the number is in a valid range and has the 
right number of digits for that range (GB numbers can be 9 or 10 digits 
long). This RegEx pattern is very detailed. You can say that a number is 
possible or is invalid with this RegEx.

RegEx Group 4. Here, there's a bunch of RegEx patterns that specify how a 
GB number should be formatted, detailed by number length and initial 
digits. These rules cover all GB numbers.

The last bit is to add the 0 or +44 back on, and append the original 
extension number (if present) and present it back to the user.

020  3000   => Valid: 020  3000  
02075  567  234 => Valid: 020  7556  7234
0114  223  4567 => Valid: 0114  223  4567
01145  345  567 => Valid: 0114  534  5567
+44  1213  456  789 => Valid: +44  121  345  6789
00  44  (0)  1697  73555 => Valid: +44  16977  3555
011  44  11  4890  2345 => Valid: +44  114  890  2345
0623 111 3456 => NOT VALID


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/h0iG7nJrXikJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.