Lines 53-58
sub validate_email {
Link Here
|
53 |
|
53 |
|
54 |
# make sure we are allowed to validate emails |
54 |
# make sure we are allowed to validate emails |
55 |
return 1 if not C4::Context->preference("ValidateEmailAddress"); |
55 |
return 1 if not C4::Context->preference("ValidateEmailAddress"); |
|
|
56 |
return 0 if $address =~ /(^(\s))|((\s)$)/; |
56 |
return 0 if not defined $address; |
57 |
return 0 if not defined $address; |
57 |
return (not defined Email::Valid->address($address)) ? 0:1; |
58 |
return (not defined Email::Valid->address($address)) ? 0:1; |
58 |
} |
59 |
} |
Lines 70-84
returns: 1 if the given phone number is valid, 0 otherwise.
Link Here
|
70 |
sub validate_phonenumber { |
71 |
sub validate_phonenumber { |
71 |
my $phonenumber = shift; |
72 |
my $phonenumber = shift; |
72 |
|
73 |
|
73 |
$phonenumber =~ s/\s+//g; |
|
|
74 |
|
75 |
# make sure we are allowed to validate phone numbers |
74 |
# make sure we are allowed to validate phone numbers |
76 |
return 1 if C4::Context->preference("ValidatePhoneNumber") eq "OFF"; |
75 |
return 1 if C4::Context->preference("ValidatePhoneNumber") eq "OFF"; |
77 |
return 1 if $phonenumber eq ""; |
76 |
return 1 if $phonenumber eq ""; |
78 |
return 0 if not defined $phonenumber; |
77 |
return 0 if not defined $phonenumber; |
79 |
|
78 |
|
80 |
my $regex = get_phonenumber_regex(C4::Context->preference("ValidatePhoneNumber")); |
79 |
my $regex = get_phonenumber_regex(C4::Context->preference("ValidatePhoneNumber")); |
81 |
#die $regex; |
|
|
82 |
return ($phonenumber !~ /$regex/) ? 0:1; |
80 |
return ($phonenumber !~ /$regex/) ? 0:1; |
83 |
} |
81 |
} |
84 |
|
82 |
|
Lines 100-106
sub get_phonenumber_regex {
Link Here
|
100 |
return qr/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/; |
98 |
return qr/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/; |
101 |
} |
99 |
} |
102 |
elsif (C4::Context->preference("ValidatePhoneNumber") eq "fin") { |
100 |
elsif (C4::Context->preference("ValidatePhoneNumber") eq "fin") { |
103 |
return qr/^((90[0-9]{3})?0|\+358\s?)(?!(100|20(0|2(0|[2-3])|9[8-9])|300|600|700|708|75(00[0-3]|(1|2)\d{2}|30[0-2]|32[0-2]|75[0-2]|98[0-2])))(4|50|10[1-9]|20(1|2(1|[4-9])|[3-9])|29|30[1-9]|71|73|75(00[3-9]|30[3-9]|32[3-9]|53[3-9]|83[3-9])|2|3|5|6|8|9|1[3-9])\s?(\d\s?){4,20}$/; |
101 |
return qr/^((90[0-9]{3})?0|\+358\s?)(?!(100|20(0|2(0|[2-3])|9[8-9])|300|600|700|708|75(00[0-3]|(1|2)\d{2}|30[0-2]|32[0-2]|75[0-2]|98[0-2])))(4|50|10[1-9]|20(1|2(1|[4-9])|[3-9])|29|30[1-9]|71|73|75(00[3-9]|30[3-9]|32[3-9]|53[3-9]|83[3-9])|2|3|5|6|8|9|1[3-9])\s?(\d\s?){4,19}\d$/; |
104 |
} |
102 |
} |
105 |
|
103 |
|
106 |
return ""; |
104 |
return ""; |