Friday, November 22, 2013

Best Practise - beforeValidate()

What is the best way when saving data for example take city or first name field.

You want it to only be a-z and a space - or.(period)

 

Should you in beforeValidate do a preg_replace and remove anything that you do not want then save(attempt) it or simply use the validation rules to check and save / return false explaining why?

 

Just curious as to how people approach this and reasons for doing it either way.

 

Thanks,

Dave

No comments: