The [FormValidator] implements html form validation capabilities.
The [FormValidator] implements html form validation capabilities. This helps with forcing constraints to input provided by users through HTML forms. [FormValidator] is the main class, it contains helper methods for adding form fields, and validations.
Construction of a simple validator:
[code]var lv : FormValidator = FormValidator.new()
lv.new_field("username", "Username").need_to_exist()
.need_to_be_alpha_numeric().need_minimum_length(5).need_maximum_length(20)
var pw : FormField = lv.new_field("password", "Password")
pw.need_to_exist()
pw.need_to_have_lowercase_character().need_to_have_uppercase_character()
pw.need_minimum_length(5)
#validation
var errors : PoolStringArray = lv.validate(request)
if (errors.size() > 0):
for i in range(errors.size()):
print(errors[i])[/code]