DEV Community

Discussion on: How To Validate Your Forms Server-Side With Octavalidate-PHP

Collapse
 
darkain profile image
Vincent Milum Jr

PHP has a lot of this functionality already built in, and battle tested. For instance, you should -never- use regular expressions to validate an email address, they'll virtually always fail.

For example, this is the ACTUAL regular expression to validate MOST of the email address spec, and yet, this STILL doesn't cover all of it: ex-parrot.com/~pdw/Mail-RFC822-Add...

Instead, PHP has built in functions to handle this, and to handle validating lots of other common data types too: php.net/manual/en/filter.examples....

Collapse
 
ugorji_simon profile image
Simon Ugorji • Edited

I'm fully with you on this.

I didn't know about the email regular expression virtually failing

I guess I learnt something new today, thank you.

I will equally update the library to use more of PHP's inbuilt validation on the form inputs.

Besides that, the validation library that I shared, helps to validate file types, file MIME types, file sizes, input lengths and provides custom regular expressions support that the user can use to validate credit card numbers, house addresses, name it...

I will heed to your advice and update the library on not to use regular expressions for email validation and to use more of PHP's inbuilt validation.

Thank you for engaging 🌟