mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-20 19:06:53 +01:00
83 lines
2.5 KiB
XML
83 lines
2.5 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<class name="FormValidator" inherits="Resource" version="4.2">
|
|
<brief_description>
|
|
The [FormValidator] implements html form validation capabilities.
|
|
</brief_description>
|
|
<description>
|
|
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]
|
|
</description>
|
|
<tutorials>
|
|
</tutorials>
|
|
<methods>
|
|
<method name="_validate" qualifiers="virtual">
|
|
<return type="void" />
|
|
<argument index="0" name="request" type="WebServerRequest" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="add_field">
|
|
<return type="void" />
|
|
<argument index="0" name="field" type="FormField" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="clear_fields">
|
|
<return type="void" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="get_field">
|
|
<return type="FormField" />
|
|
<argument index="0" name="index" type="int" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="get_field_count" qualifiers="const">
|
|
<return type="int" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="new_field">
|
|
<return type="FormField" />
|
|
<argument index="0" name="name" type="String" />
|
|
<argument index="1" name="human_name" type="String" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="remove_field">
|
|
<return type="void" />
|
|
<argument index="0" name="index" type="int" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="validate">
|
|
<return type="PoolStringArray" />
|
|
<argument index="0" name="request" type="WebServerRequest" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
</methods>
|
|
<members>
|
|
<member name="fields" type="Array" setter="set_fields" getter="get_fields" default="[ ]">
|
|
</member>
|
|
</members>
|
|
<constants>
|
|
</constants>
|
|
</class>
|