You are here

Validation in Web-D-Zine( WDZ )

Good or Bad

The validation class comes with a lot of pre-built functions to validate data, some of which use the validation filters ( https://www.php.net/manual/en/filter.filters.validate.php ) while others are bespoke

Validation filters

  • BOOLEAN - Allows 1, true, on, yes, 0, false, off and no
  • DOMAIN - Validates whether the domain name label lengths are valid.
  • EMAIL - Validates whether the value is a valid e-mail address.
  • FLOAT - Validates value as float
  • INT - Validates value as integer
  • IP - Validates value as IP address
  • MAC - Validates value as MAC address
  • REGEXP - Validates value against regexp
  • URL - Validates value as URL

Bespoke validation

  • money - Limits value to 2 decimal places and does not allow e numbers.
  • postcode - Validates UK Postcodes
  • tel - Validates Telephone number
  • date - Validates date
  • date-time - Validates datetime
  • month - Makes sure that the input complies with the format YYYY-MM then does a further check to make sure the month is >0 and <13
  • time - Validates time.
  • week - makes sure that the input complies with YYYY-W week. Additional check that the week >0 and <54
  • unique - Only characters within the unique set of characters are allowed
  • captcha - This validation occurs automatically if you use a capcha element in your form

Validation is contained within a class so that if an extra validation is required then the class can be extended

In addition to this validation, the class also checks if a field is required

Image by Niek Verlaan from Pixabay

FAQ

Author: Gaynor Portlock

Category
Latest News
Can dreams come true at 60
Well that is a question, that only the universe can answer, but what we can state here is truth and dreams Read more