Skip to content
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

Inconsistent validation behaviour between onCreate and onSave #1059

Open
andybellenie opened this issue Feb 26, 2021 · 1 comment
Open

Inconsistent validation behaviour between onCreate and onSave #1059

andybellenie opened this issue Feb 26, 2021 · 1 comment

Comments

@andybellenie
Copy link
Contributor

I've found some odd behaviour which I think should be considered a bug.

When creating custom validations, your app may behave differently depending on whether you use

<cfset validate(methods="validateProperties", when="onCreate")>

or

<cfset validate(methods="validateProperties", when="onSave")>

Specifically, the order of events will be different.

Using onSave, Wheels will run your custom validation first, then automatic validations. Using onCreate, it will run automatic validations first.

This is because of the way validations are stored in two separate arrays in variables.wheels.class.validations.

In the example of the app I am currently working on, it was failing create validation when using onCreate but passing when using onSave, because of this ordering issue, when it should make no difference. I could code around it, but it could really confuse someone less familiar with Wheels than I am.

@neokoenig neokoenig added this to the 2.3.0 milestone Apr 20, 2021
@zainforbjs
Copy link
Contributor

@andybellenie Can you specify what validations you were using so that I can have some context to test with and maybe find a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants