Skip to content

Commit

Permalink
Merge pull request #1989 from shivendra-webkul/postcode
Browse files Browse the repository at this point in the history
Update postcode validation and fix postcode validation issues
  • Loading branch information
devansh-webkul authored Jan 21, 2025
2 parents fa41f92 + c95788e commit 8cef69f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
/>
<x-admin::form.control-group.error ::name="attribute['code'] + '[postcode]'" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class="primary-button"
'max:100',
],
'postcode' => [
'max:20',
'postcode',
],
]"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class="primary-button"
'max:100',
],
'postcode' => [
'max:20',
'postcode',
],
]"
:entity="$organization"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class="primary-button"
'max:100',
],
'postcode' => [
'max:20',
'postcode',
],
]"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class="primary-button"
'max:100',
],
'postcode' => [
'max:20',
'postcode',
],
]"
:entity="$warehouse"
Expand Down

0 comments on commit 8cef69f

Please sign in to comment.