-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address validation rule order #1417
Comments
Hi @NixonGit I have run some test cases and I can't seem to get the error you mentioned. It works no matter if the Do you have a stack trace for this? Thanks. |
Here's the post data
And here are our custom validation rules: Event::on(Address::class, Address::EVENT_DEFINE_RULES, function(DefineRulesEvent $event) {
$event->rules[] = [['firstName', 'lastName'], 'required'];
$event->rules[] = ['address1', 'required', 'message' => 'Address cannot be blank'];
$event->rules[] = ['zipCode', 'required', 'message' => 'Post Code cannot be blank'];
$event->rules[] = ['countryId', 'default', 'value' => 77];
$event->rules[] = ['countryId', 'compare', 'compareValue' => 77, 'message' => 'We only ship to the United Kingdom'];
}); |
HI @NixonGit Thank you for all of the info. We have pushed up a fix that should address this and bring back a validation error. It will be included in the next release. To get this early, change your "require": {
"craftcms/commerce": "dev-develop#8bc118b0a07fd82be66bfc9ca8d601be8abc4781 as 3.1.3",
"...": "..."
} Then run Thanks. |
Description
We have an order form that when validating the
Address
model throws an exception if thecountryCode
isn't an integer, stemming from thevalidateState
rule. We believe the root cause of this is if the address fields gets autofilled by the browser or an extension.We're using
Address::EVENT_DEFINE_RULES
to try and catch this but they get called after the 1st party rules.Steps to reproduce
Additional info
The text was updated successfully, but these errors were encountered: