ClearOS Documentation

×

Warning

301 error for file:https://clearos.com/dokuwiki2/lib/exe/css.php?t=dokuwiki&tseed=82873f9c9a1f5784b951644363f20ef8

User Tools

Site Tools


Input Validation

All ClearOS libraries should maintain their own validation routines for consistency. For example, dnsmasq→validate_gateway() should be created and used instead of making the developer poke around for the network_utils→validate_ip. Why? Consistency. Every application may have slightly different needs. For example, 192.168.3.3 is certainly a valid IP but it's not a valid DHCP gateway address for a 10.0.0.0 network. Instead of making a developer guess how to pre-validate a dnsmasq→set_gateway method, they can count on seeing an dnsmasq→validate_gateway method.

The validation methods can certainly call generic routines, e.g. dnsmasq→validate_gateway uses network_utils→validate_ip. That is to be encouraged of course!

Validation 101

  • Check the date type
  • Check the length
  • Match an appropriate regular expression
  • Escape the data if necessary
content/en_us/dev_framework_reference_guide_input_validation.txt · Last modified: 2015/02/05 19:49 (external edit)

https://clearos.com/dokuwiki2/lib/exe/indexer.php?id=content%3Aen_us%3Adev_framework_reference_guide_input_validation&1563884944