Validation in Elanat
elanatframework
Posted on September 8, 2023
Note: First, I would like to say that Elanat is completely implemented based on ASP.NET Core, but it is implemented based on the CodeBehind framework in the form of MVC. If you see in this article that the name of the aspx pages is written or the view structure is not similar to the default ASP.NET Core cshtml, you can refer to the following link to learn more about the CodeBehind framework:
https://github.com/elanatframework/Code_behind
Elanat uses its own internal validation structure. This structure works dynamically and keeps all validations related to each set of sent data inside an XML file.
An example of a validation.xml file related to the category component in Elanat:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<validation_root>
<validation_list>
<CheckBoxList id="cbxlst_CategoryAccessShow" type="number" label="category_access_show" category="" start_range="0" end_range="100000" important="false" client_injection_check="true" />
<DropDownList id="ddlst_CategorySite" type="number" label="category_site" category="" start_range="0" end_range="100000" important="false" client_injection_check="true" />
<DropDownList id="ddlst_DefaultStyle" type="number" label="default_style" category="" start_range="0" end_range="100000" important="false" client_injection_check="true" />
<DropDownList id="ddlst_DefaultTemplate" type="number" label="default_template" category="" start_range="0" end_range="100000" important="false" client_injection_check="true" />
<DropDownList id="ddlst_ParentCategory" type="number" label="parent_category" category="" start_range="0" end_range="100000" important="false" client_injection_check="true" />
<TextBox id="txt_CategoryName" type="ul_string" label="category_name" category="" min_count="1" max_length="50" important="true" is_unique="true" unauthorized_check="true" table_name="el_category" column_name="category_name" />
</validation_list>
</validation_root>
validation.xml files are managed by the ValidationClass class; You can access the ValidationClass codes by referring to the following link:
Using this structure will have many advantages. The most important advantage of using this validation model in Elanat is that it allows great personalization to the user. You can accept only a few specific email domains or create illegal names, remove the requirement to fill in the field, show your unique style to the user, do not allow duplicate fields to be registered in the database, avoid injecting Avoid select lists and many other things that you need based on your needs.
ASP.NET developers usually use DataAnnotations (or similar it) to control the values of form submissions. You should note that using DataAnnotations to control the values of submitted forms will leave your system structure out of dynamic mode. Also, the possibility of any changes only requires republishing, and it is the programmer who will have the ability to make possible changes (with a lot of trouble for republishing), and end users face a closed ecosystem.
The validation.xml files related to each add-on in Elanat are placed in the path .../add-on_path/App_Data/validation_list/validation.xml.
During the execution of the aspx page, arbitrary values are placed on the class name or as attributes on the inputs; The following codes show a small part of the aspx file related to the category component:
aspx file
<div class="el_item">
<input id="txt_CategoryName" name="txt_CategoryName" type="text" value="<%=model.CategoryNameValue%>" class="el_text_input<%=model.CategoryNameCssClass%>" <%=model.CategoryNameAttribute%> />
</div>
After execution
<div class="el_item">
<input id="txt_CategoryName" name="txt_CategoryName" type="text" value="" class="el_text_input el_warning_field" maxlength="50">
</div>
As you can see, el_warning_field has been added in the text input class and the maxlength attribute with a value of 50 has been added to the text input.
Validation in Elanat also checks unauthorized values.
The unauthorized.xml files related to each add-on in Elanat are placed in the path .../add-on_path/App_Data/unauthorized_list/unauthorized.xml.
An example of a unauthorized.xml file related to the category component in Elanat:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<unauthorized_root>
<unauthorized_list>
<el_category>
<category_name>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_with_alt_and_255_is_unauthorized"> </unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_pound_is_unauthorized">#</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_percent_is_unauthorized">%</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_ampersand_is_unauthorized"><![CDATA[&]]></unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_left_curly_bracket_is_unauthorized">{</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_right_curly_bracket_is_unauthorized">}</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_back_slash_is_unauthorized">\</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_left_angle_bracket_is_unauthorized"><![CDATA[<]]></unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_right_angle_bracket_is_unauthorized"><![CDATA[>]]></unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_asterisk_is_unauthorized">*</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_question_mark_is_unauthorized">?</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_forward_slash_is_unauthorized">/</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_dollar_sign_is_unauthorized">$</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_exclamation_point_is_unauthorized">!</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_single_quotes_is_unauthorized">'</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_double_quotes_is_unauthorized">"</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_colon_is_unauthorized">:</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_semicolon_is_unauthorized">;</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_at_sign_is_unauthorized">@</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_plus_sign_is_unauthorized">+</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_backtick_is_unauthorized">`</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_pipe_is_unauthorized">|</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_equal_sign_is_unauthorized">=</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_caret_is_unauthorized">^</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_opening_bracket_is_unauthorized">[</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_closing_bracket_is_unauthorized">]</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_open_parenthesis_is_unauthorized">(</unauthorized>
<unauthorized exist="true" start_by="false" end_by="false" reason="character_close_parenthesis_is_unauthorized">)</unauthorized>
</category_name>
</el_category>
</unauthorized_list>
</unauthorized_root>
Validation in Elanat also supports regex. The following tag shows email validation with regex:
<TextBox id="txt_EmailSender" type="string" label="email_sender" format="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$" category="email" min_count="0" max_length="254" important="false" />
You can check a large validation.xml file in Elanat by referring to the link below:
Validation messages in Elanat can be translated and communicate with language packages; Also, the powerful el_AjaxPostBack function on the client side automatically manages the display of warnings.
Posted on September 8, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.