validateOnChangeOrBlur or validateOnChangeAndBlur

It seems that with the aurelia validation v2 that validateOnChangeOrBlur only triggers validation after you change the value and then move to a next field. So it should be validateOnChangeAndBlur instead?

See:

The “Or” in the name still makes sense. What you are seeing is for the first validation. After that validation is triggered on change. The reasoning behind the new behavior is discussed in this related thread.

This means that when a user sets focus to an input and then moves to the next input with no text editing then no validation is taken place with validateOnChangeOrBlur.
So if you set a required validation rule on the value in combination with validateOnChangeOrBlur then this is only usable to check if the user first set the value and then empty it and then moves to the next field.
Or am I missing something?

Yes, something like that. Moreover, you can at anytime call the validationController.validate() to perform the validation. When submitting (a form), the form/input can be validated by calling validationController.validate(). If that produces a validation error for your above mentioned case, it goes away as soon as user enters a valid value.

I am still trying to understand what you mean by ‘What you are seeing is for the first validation’.

In the thread the following is said:

Firstly the changrOrEVENT trigger (where EVENT is blur or focusout ) does not trigger the validation until the field is either validated by one of the EVENT -triggered validation or manual validation.

So what my understanding of above is that the first validation should be triggered when the BLUR event is fired, even when the value itself is not changed. But my test showed something different.

The source code documentation is also not really clear.

changeOrBlur
With Validate the binding when the binding’s target element fires a DOM “blur” event and when it updates the model due to a change in the view.

changeOrFocusout
Validate the binding when the binding’s target element fires a DOM “focusout” event or when it updates the model due to a change in the view.

So with the blur it states and and with focusout it states or.

That is not the case. According to the new changeOrEVENT strategy, the validation of the unchanged value is skipped, even when the event (focusout or blur) occurs. The justification for this comes from the objective of reducing the “yelling” at the user, as pointed out in the linked thread.

The issue with the documentation as you pointed out is a slip up. Thank you for pointing that out. You are welcomed to submit a PR for that :slight_smile: