Form validation with native PHP function |
[eluser]dinhtrung[/eluser]
Hi everyone, I wonder why CI does not support some native PHP function for validation, like file_exists(), is_dir, is_readable, is_writable ? I have a textbox for user to type in the file name or directory name, and I want to use all 4 functions above to validate the user input. All though I set the rule correctly, but it not work. Dive into the Form_validation class, I found that for native PHP functions like that, only post data is effects. I can only use function to change the value, like md5, base64 or strip_tags (without the 2nd param). My Idea is, CI Form_validation should handle all this function, and 2nd parameters as well. Any idea?
[eluser]Boris Strahija[/eluser]
Those are not functions that should be in the form validation lib. Anyway, it's easy enough to create a callback rule for what you need.
[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-gui...eppingdata Quote:Any native PHP function that accepts one parameter can be used as a rule, like htmlspecialchars, trim, MD5, etc. If you need to validate with these rules, like Boris Strahija said, you can create a callback to do so. |
Welcome Guest, Not a member yet? Register Sign In |