Mandatory field via deluge code

Mandatory field via deluge code

I would like to ask you if it is possible to make a field mandatory via deluge script.

For example, if I have a decision box and I click on it then I want a single line field to be mandatory. If uncheck the decision box then to do the single line as optional.

I think it is not possible to do that and I have to do it via validation in 'on validate' field.