How to access other fields of the same entity in a field validator?

Hi
I have a field(let’s call it f#1) in the entity whose validation is dependent on another field(f#2) of the same entity. Can i access that f#2’s value in the validator of f#1? If yes, how?

1 Like

You can create a validator instance and assign it to the field programmatically - see an example at the end of this section: https://doc.cuba-platform.com/manual-6.2/gui_validator.html
In this case your validator class does not have to be static and can have access to all controller fields and methods. So you can read the value of the second field.

1 Like

Can you please break down some of the Objects/Functions in this example?
i.e.
What is parameter.getRequired() doing and where is parameter being sourced from?

Where is the tokenList object coming from?

If this code sample can read from other fields, which variables are holding the values of the other fields?