XSS Validation Model Rule

Hey folks,

basically i know how to prevent XSS in Yii2.
I know there are 2 Helpers for that.

I am using Yii2 as Backend and not as Frontend.
I want to check in Model Validation for XSS and if there is something then the Validation fails.

How do i achieve that?

I tried out that: validation - Yii2 : How to validate XSS (Cross Site Scripting) in form / model input? - Stack Overflow
But that only achieves that the XSS Code gets removed but the Validation doesn’t fail.

Put some details including what you have attempted: