diff --git a/packages/Webkul/Admin/src/Resources/assets/js/plugins/vee-validate.js b/packages/Webkul/Admin/src/Resources/assets/js/plugins/vee-validate.js index 95edb1788..018bf0529 100644 --- a/packages/Webkul/Admin/src/Resources/assets/js/plugins/vee-validate.js +++ b/packages/Webkul/Admin/src/Resources/assets/js/plugins/vee-validate.js @@ -79,6 +79,18 @@ export default { return true; }); + defineRule("postcode", (value) => { + if (! value || ! value.length) { + return true; + } + + if (! /^[a-zA-Z0-9][a-zA-Z0-9\s-]*[a-zA-Z0-9]$/.test(value)) { + return false; + } + + return true; + }); + defineRule("decimal", (value, { decimals = '*', separator = '.' } = {}) => { if (value === null || value === undefined || value === '') { return true; diff --git a/packages/Webkul/Admin/src/Resources/views/components/attributes/edit/address.blade.php b/packages/Webkul/Admin/src/Resources/views/components/attributes/edit/address.blade.php index ef1bcfe2d..658ad21b9 100644 --- a/packages/Webkul/Admin/src/Resources/views/components/attributes/edit/address.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/components/attributes/edit/address.blade.php @@ -123,7 +123,7 @@ ::value="data && data['postcode'] ? data['postcode'] : ''" :placeholder="trans('admin::app.common.custom-attributes.postcode')" :label="trans('admin::app.common.custom-attributes.postcode')" - ::rules="attribute.is_required ? 'required|min:5|max:10' : 'min:5|max:10'" + ::rules="attribute.is_required ? 'required|postcode' : 'postcode'" /> diff --git a/packages/Webkul/Admin/src/Resources/views/contacts/organizations/create.blade.php b/packages/Webkul/Admin/src/Resources/views/contacts/organizations/create.blade.php index 046483335..63722fc33 100644 --- a/packages/Webkul/Admin/src/Resources/views/contacts/organizations/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/contacts/organizations/create.blade.php @@ -61,7 +61,7 @@ class="primary-button" 'max:100', ], 'postcode' => [ - 'max:20', + 'postcode', ], ]" /> diff --git a/packages/Webkul/Admin/src/Resources/views/contacts/organizations/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/contacts/organizations/edit.blade.php index 04877ba61..3ff41af43 100644 --- a/packages/Webkul/Admin/src/Resources/views/contacts/organizations/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/contacts/organizations/edit.blade.php @@ -62,7 +62,7 @@ class="primary-button" 'max:100', ], 'postcode' => [ - 'max:20', + 'postcode', ], ]" :entity="$organization" diff --git a/packages/Webkul/Admin/src/Resources/views/settings/warehouses/create.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/warehouses/create.blade.php index e02d44a21..f028f2c01 100644 --- a/packages/Webkul/Admin/src/Resources/views/settings/warehouses/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/settings/warehouses/create.blade.php @@ -65,7 +65,7 @@ class="primary-button" 'max:100', ], 'postcode' => [ - 'max:20', + 'postcode', ], ]" /> diff --git a/packages/Webkul/Admin/src/Resources/views/settings/warehouses/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/warehouses/edit.blade.php index bc9edc7a7..8534e1f26 100644 --- a/packages/Webkul/Admin/src/Resources/views/settings/warehouses/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/settings/warehouses/edit.blade.php @@ -68,7 +68,7 @@ class="primary-button" 'max:100', ], 'postcode' => [ - 'max:20', + 'postcode', ], ]" :entity="$warehouse"