Commit 5dfd54681501c23099a6ca4d4552e632c7bf013e
1 parent
5fa4fc17
Exists in
master
and in
5 other branches
Remove validation of name begin with capital letter
Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: Parley Martins <parley@outlook.com>
Showing
2 changed files
with
0 additions
and
89 deletions
Show diff stats
lib/ext/person.rb
@@ -8,8 +8,6 @@ class Person | @@ -8,8 +8,6 @@ class Person | ||
8 | 8 | ||
9 | attr_accessible :percentage_incomplete | 9 | attr_accessible :percentage_incomplete |
10 | 10 | ||
11 | - validate :validate_full_name | ||
12 | - | ||
13 | scope :search, lambda { |name="", state="", city="", email=""| | 11 | scope :search, lambda { |name="", state="", city="", email=""| |
14 | like_sql = "" | 12 | like_sql = "" |
15 | values = [] | 13 | values = [] |
@@ -59,51 +57,8 @@ class Person | @@ -59,51 +57,8 @@ class Person | ||
59 | self.user.secondary_email = value unless self.user.nil? | 57 | self.user.secondary_email = value unless self.user.nil? |
60 | end | 58 | end |
61 | 59 | ||
62 | - def validate_full_name | ||
63 | - full_validation = /([^\w\*\s*])|(^|\s)([a-z]|[0-9])/ | ||
64 | - partial_validation = /[^\w\*\s]/ | ||
65 | - invalid = false | ||
66 | - | ||
67 | - return false if self.name.blank? | ||
68 | - | ||
69 | - validation_name = replace_some_special_chars(self.name) | ||
70 | - | ||
71 | - validation_name.split(" ").each do |value| | ||
72 | - invalid = if value.length > 3 | ||
73 | - full_validation.match(value) | ||
74 | - else | ||
75 | - partial_validation.match(value) | ||
76 | - end | ||
77 | - end | ||
78 | - | ||
79 | - if invalid | ||
80 | - self.errors.add(:name, _("Should begin with a capital letter and no special characters")) | ||
81 | - return false | ||
82 | - end | ||
83 | - true | ||
84 | - end | ||
85 | - | ||
86 | def software? | 60 | def software? |
87 | false | 61 | false |
88 | end | 62 | end |
89 | 63 | ||
90 | - private | ||
91 | - | ||
92 | - def replace_some_special_chars text | ||
93 | - text.gsub(/([áàâãéèêíïóôõöú])/) do |value| | ||
94 | - if( ["á","à","â","ã"].include?(value) ) | ||
95 | - "a" | ||
96 | - elsif( ["é","è","ê"].include?(value) ) | ||
97 | - "e" | ||
98 | - elsif( ["í","ï"].include?(value) ) | ||
99 | - "i" | ||
100 | - elsif ( ["ó","ô","õ","ö"].include?(value) ) | ||
101 | - "o" | ||
102 | - elsif( ["ú"].indexOf(value) ) | ||
103 | - "u" | ||
104 | - else | ||
105 | - value | ||
106 | - end | ||
107 | - end | ||
108 | - end | ||
109 | end | 64 | end |
public/mpog-user-validations.js
@@ -209,49 +209,6 @@ | @@ -209,49 +209,6 @@ | ||
209 | }); | 209 | }); |
210 | } | 210 | } |
211 | 211 | ||
212 | - // Sorry, I know its ugly. But I cant get ([^\w\*\s*])|(^|\s)([a-z]|[0-9]) | ||
213 | - // to ignore Brazilian not so much special chars in names | ||
214 | - function replace_some_special_chars(text) { | ||
215 | - return text.replace(/([áàâãéèêíïóôõöú])/g, function(value){ | ||
216 | - if( ["á","à","â","ã"].indexOf(value) != -1 ) | ||
217 | - return "a"; | ||
218 | - else if( ["é","è","ê"].indexOf(value) != -1 ) | ||
219 | - return "e"; | ||
220 | - else if( ["í","ï"].indexOf(value) != -1 ) | ||
221 | - return "i"; | ||
222 | - else if ( ["ó","ô","õ","ö"].indexOf(value) != -1 ) | ||
223 | - return "o"; | ||
224 | - else if( ["ú"].indexOf(value) != -1 ) | ||
225 | - return "u"; | ||
226 | - else | ||
227 | - return value; | ||
228 | - }); | ||
229 | - } | ||
230 | - | ||
231 | - function invalid_name_validation(text) { | ||
232 | - if( text.trim().length === 0 ) { | ||
233 | - return true; | ||
234 | - } | ||
235 | - | ||
236 | - var full_validation = /([^\w\*\s*])|(^|\s)([a-z]|[0-9])/; // no special chars and do not initialize with no capital latter | ||
237 | - var partial_validation = /[^\w\*\s*]/; // no special chars | ||
238 | - text = replace_some_special_chars(text); | ||
239 | - var slices = text.split(" "); | ||
240 | - var invalid = false; | ||
241 | - | ||
242 | - for(var i = 0; i < slices.length; i++) { | ||
243 | - if( slices[i].length > 3 || text.length <= 3 ) { | ||
244 | - invalid = full_validation.test(slices[i]); | ||
245 | - } else { | ||
246 | - invalid = partial_validation.test(slices[i]); | ||
247 | - } | ||
248 | - | ||
249 | - if(invalid) break; | ||
250 | - } | ||
251 | - | ||
252 | - return invalid; | ||
253 | - } | ||
254 | - | ||
255 | // Generic | 212 | // Generic |
256 | function show_plugin_error_message(field_selector, hidden_message_id ) { | 213 | function show_plugin_error_message(field_selector, hidden_message_id ) { |
257 | var field = jQuery(field_selector); | 214 | var field = jQuery(field_selector); |
@@ -392,7 +349,6 @@ | @@ -392,7 +349,6 @@ | ||
392 | fix_phone_mask_format("#profile_data_comercial_phone"); | 349 | fix_phone_mask_format("#profile_data_comercial_phone"); |
393 | fix_phone_mask_format("#profile_data_contact_phone"); | 350 | fix_phone_mask_format("#profile_data_contact_phone"); |
394 | 351 | ||
395 | - addBlurFields("#profile_data_name", "full_name_error", invalid_name_validation); | ||
396 | addBlurFields("#profile_data_email", "email_error", invalid_email_validation); | 352 | addBlurFields("#profile_data_email", "email_error", invalid_email_validation); |
397 | addBlurFields("#user_secondary_email", "email_error", invalid_email_validation, true); | 353 | addBlurFields("#user_secondary_email", "email_error", invalid_email_validation, true); |
398 | addBlurFields("#profile_data_personal_website", "site_error", invalid_site_validation); | 354 | addBlurFields("#profile_data_personal_website", "site_error", invalid_site_validation); |