Possible to set invalid values through macro and automation

I’m trying to automate LibreOffice and noticed I could set invalid values for certain cells.

I set one cell to only accept whole numbers (through Data>Validity>Whole Numbers) and even though it works when entering these values manually (when entering 1,5 or 1.5 I get the error), I can set it through a macro or automation.

This is also the case for validation LIST where I can set an invalid value for a cell (not in the list given).

Is there a function or method I can use to receive an error or check for validity for a cell before I push a value to it?

B.T.W. Even using Data>Form, where all rows are presented in Form-view, I can enter invalid values.
So Data>Validity isn’t really checked in lots of places.

Checking data input validity is an UI feature while the user enters values. AFAIK there is no option to check macro generated cell content against TableValidation settings.

Thank you for your answer. I was hoping there was some interface to the validation but I guess I have to do the validation by code in this case.