Combining regular validation with fmshook validation

The documentation for this is woefully inadequate:

I’m trying to combine regular validation with some custom validation on one field. When the onFieldValidation hook runs, it clears all of the rest of the validation messages on the form. If I disable the custom onFieldValidation scripting in FM, the other validation messages persist.

This is where the documentation is confusing:

### onFieldValidationHook

This hook is called when a field has been assigned an `fmsHook` validator.

The `.validation` object is broken out for you in the var `$validation` You can make business logic decisions based on the data here. The rest of the other objects are also available including `$actions` so you can inject workflow changes too.

To pass back validation error messages set the `validation.error` element to your error message.

There is no $validation variable in the script when it runs.
Setting anything to do with $validation also does nothing to pass data back to BF
This comment in the script is also confusing:
To return validation.error : "Your Error message or empty"

Can someone please update this documentation with a better example?

Starting to find my own answers here.

Set a variable to find out which field is being validated:

JSONGetElement( $$BF_Payload ; "data.validation.field.model" )

Mutate $$BF_Payload directly with an error message:

JSONSetElement( $$BF_Payload ; "data.validation.error[0]"  ; "This failed validation for some reason..." ; JSONString )

You can also validate the field by returning an empty string:

JSONSetElement( $$BF_Payload ; "data.validation.error[0]"  ; "" ; JSONString )

Still having some weird issues, like my message is displayed twice the first time the field is validated, even though the envelope in the inbox only has the single error message.

It is also still clearing all of the other validation messages as well.

Also, is it really necessary to include the entire model as part of data.validation.model key? Shouldn’t data.validation.model be enough combined with $$BF_Model?

Screenshot 2023-02-28 at 5.42.04 PM