content:en_us:dev_framework_reference_guide_input_validation

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

search?q=clearos%2C%20clearos%20content%2C%20dev%2C%20framework%2C%20other%2C%20maintainer_dloper&btnI=lucky

content/en_us/dev_framework_reference_guide_input_validation.txt · Last modified: 2015/02/06 02:49 (external edit)

Page Tools