Developers Documentation



301 error for file:

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, is certainly a valid IP but it's not a valid DHCP gateway address for a 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)