Is it possible to pass attributes from a page into a validator as a parameter for use in its logic? I'm trying to pass the Id of the record into an async validator which should then query the database for the record to check whether it is in a valid state to be saved, but I don't seem to be able to pass the attribute in as a parameter and it isn't available by default in the validator. I've tried the below:
But it just passes in the literal string "$Id" instead of the value of Id. I don't see anything about passing dynamic values into validators in the documentation.
They are working for me. One thing I did initially was add it to the control in the viewConfigDiff. You're actually supposed to add the validator to the attribute in the viewModelConfig - not to the control in the diff. Once I moved it there it worked. Your column is likely in the viewModelConfig already (if it's been added to the page). Look for it there and just add the validator to that existing attribute in the model.
Hmm. Not sure about that. I've only used validators where I need the control's value only (which is provided in the params passed in). I had assumed you could pass in other values in the validator params, but that doesn't seem to be the case (or at least I can't figure out how that works). Hopefully we'll see more documentation soon.
Currently, the R&D team is working on such task, they plan to create a solution in the next releases. You can try to workaround in this way: On the field's change add a custom handler, set a flag in it, look at this global flag (atribute's value) in the validator.
Most likely to validate "if end date it's not before the begin date" you can use in handler await request.$context.DateTimeAttribute_nnnn