All Validation Rules and Description:

Rule Description
validate-no-html-tags HTML tags are not allowed.
validate-select Select an option.
validate-no-empty Empty Value
validate-alphanum-with-spaces Use letters (a-z or A-Z), numbers (0-9), or spaces only in this field.
validate-data Use letters (a-z or A-Z), numbers (0-9), or underscores (_) only in this field. The first character should be a letter.
validate-street Use letters (a-z or A-Z), numbers (0-9), spaces, and “#” only in this field.
validate-phoneStrict Enter a valid phone number. For example, (123) 456-7890 or 123-456-7890.
validate-phoneLax Enter a valid phone number. For example, (123) 456-7890 or 123-456-7890.
validate-fax Enter a valid fax number. For example, 123-456-7890.
validate-email Enter a valid email address. For example, johndoe@domain.com.
validate-emailSender Enter a valid email address. For example, johndoe@domain.com.
validate-password Enter 6 or more characters. Leading and trailing spaces will be ignored.
validate-admin-password Enter 7 or more characters, using both numeric and alphabetic.
validate-url Enter a valid URL. Protocol is required (http://, https:// or ftp://).
validate-clean-url Enter a valid URL. For example, http://www.example.com or www.example.com.
validate-xml-identifier Enter a valid XML-identifier. For example, something_1, block5, id-4.
validate-ssn Enter a valid social security number. For example, 123-45-6789.
validate-zip-us Enter a valid ZIP code. For example, 90602 or 90602-1234.
validate-date-au Use this date format: dd/mm/yyyy. For example, 17/03/2006 for the 17th of March, 2006.
validate-currency-dollar Enter a valid $ amount. For example, $100.00.

Example How to use:

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        
<section id="your_section_id" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Bla Bla Bla</label>
            <tab>your_tab</tab>
            <resource>Your_Resource::xyz</resource>
            <group id="xyz_configuration" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>xyz Configuration</label>
                <field id="cart_max_qty" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Maximum Qty Allowed Cart To Quote</label>
                    <comment>Please enter Maximum Allowed Qty.</comment>
                    <validate>validate-number validate-greater-than-zero</validate>
                </field>
                <field id="cart_max_subtotal" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Cart Maximum Subtotal Ammount</label>
                    <comment>Please enter Maximum Allowed Cart Subtotal.</comment>
                    <validate>required-entry validate-number</validate>
                </field>
            </group>
        </section>

    </system>
</config>

Categories: Magento

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *