Page 1 of 1

Validating strings

Posted: Fri Dec 03, 2010 4:57 am
by matthijs
What sort of validation do you use for the validation of strings? Say you have form fields for user input of names, or street, etc.

What I have now are NotEmpty and StringLength. So a family name must be filled in and be between 1 and 100 characters long. Could also be 200 chars (you never know what strange long name someone might have.

However, I'm not sure what else to do. Like alnum is too restrictive. And I haven't come up with a good regex yet. Most of them are too restrictive for general use. A user might have characters other then the regular abc in his name (think French, Hebrew, etc)

Re: Validating strings

Posted: Fri Dec 03, 2010 1:36 pm
by social_experiment
NotEmpty is my validation method of choice, come to think of it, with names / surnames etc I haven't really done any 'checking' for alphabet characters :? The point about the non-english names is good one, not one i paid attention to it until this very second probably because most of my work is done for clients with english as a first or second language. It's not a good idea too assume though that their clients or users will also have 'english-alphabet' safe names / surnames.