Is there a way to add a validation without attaching it to an input field?

Is there a way to add a validation without attaching it to an input field?

is there a way to add a validation without attaching it to an input field?