Created
June 17, 2019 11:44
-
-
Save magevision/988f46f0df9bad3939e7b1976d19c3b4 to your computer and use it in GitHub Desktop.
AddCustomValidationSystemConfigurationField
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var config = { | |
config: { | |
mixins: { | |
'mage/validation': { | |
'MageVision_Blog48/js/system/config/validator-rules-mixin': true | |
} | |
} | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> | |
<tab id="magevision" translate="label" sortOrder="1000"> | |
<label>MageVision Blog Posts</label> | |
</tab> | |
<section id="blog48" translate="label" type="text" sortOrder="1010" showInDefault="1" showInWebsite="1" showInStore="1"> | |
<label>Post 48</label> | |
<tab>magevision</tab> | |
<resource>MageVision_Blog48::blog48_configuration</resource> | |
<group id="post48" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> | |
<label>General</label> | |
<field id="custom_validation" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> | |
<label>Custom Validation Greater than 1</label> | |
<validate>validate-greater-than-one</validate> | |
</field> | |
</group> | |
</section> | |
</system> | |
</config> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'jquery' | |
], function ($) { | |
'use strict'; | |
return function (target) { | |
$.validator.addMethod( | |
'validate-greater-than-one', | |
function (value) { | |
return !(value <= 1); | |
}, | |
$.mage.__('Please enter a number 2 or greater in this field.') | |
); | |
return target; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment