pandemonium_engine/modules/web/doc_classes/FormValidator.xml

83 lines
2.5 KiB
XML
Raw Normal View History

2022-08-21 00:40:49 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2024-02-25 10:26:26 +01:00
<class name="FormValidator" inherits="Resource" version="4.3">
2022-08-21 00:40:49 +02:00
<brief_description>
The [FormValidator] implements html form validation capabilities.
2022-08-21 00:40:49 +02:00
</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()
2022-08-23 13:09:12 +02:00
lv.new_field("username", "Username").need_to_exist()
.need_to_be_alpha_numeric().need_minimum_length(5).need_maximum_length(20)
2022-08-23 13:09:12 +02:00
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() &gt; 0):
for i in range(errors.size()):
print(errors[i])[/code]
2022-08-21 00:40:49 +02:00
</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>