Frontend form validation I need to validate the form submitted at the frontend by applying additional validation rules.

For that I have created the plugin that listens to "EVENT_BEFORE_SAVE_ENTRY" event and should validate input fields of the form. 

Yii2 documentation suggests to override model rules() method to add custom rules, and then to apply validate() method.

The problem is that I cannot find how to override default rules of the Entry class, and how to use overridden classes as entries in Craft3. 
Also I need to filter saving entry data from script tags of slashes to prevent script injection.

I am quite new to the Craft3, so please prodive some code examples and where exactly should I put my code
Thank you in advance!
I ended up using the Ad Hoc Validation method of Yii2, here is the link for documentation: 
https://www.yiiframework.com/doc/guide/2.0/en/input-validation#ad-hoc-validation

My code for validation: 
Plugin.php

class Plugin extends \craft\base\Plugin

{
    public function init()
{
    parent::init();

    $this-&gt;setComponents([
        'form1Validator' =&gt; Form1Validator::class,
        ...
    ]);

    Event::on(
        SaveController::class,
        SaveController::EVENT_BEFORE_SAVE_ENTRY,
        function(SaveEvent $event) {
            try {
                $response = null;
                switch($event-&gt;entry-&gt;section-&gt;handle) {
                    case 'form1':
                        $response = Plugin::getInstance()-&gt;form1Validator-&gt;validate($event-&gt;entry);
                        break;
                    ...
                        }
                }
                if(!isset($response) || !$response['success']){
                    $event-&gt;isValid = false;
                    $event-&gt;entry-&gt;addErrors($response['errors']);
                }
            } catch (\Exception $e) {
                $event-&gt;isValid = false;
                $event-&gt;entry-&gt;addError('exception', $e-&gt;getMessage());
                return;
            }
        }
    );
}


}

Form1Validator.php

class Form1Validator
{
 public function validate(Entry $entry)
{
    $model = new DynamicModel(
        [
            'formGender' =&gt; $entry-&gt;formGender,
            'formFirstName' =&gt; $entry-&gt;formFirstName,
            'formLastName' =&gt; $entry-&gt;formLastName,
            'formEmailAddress' =&gt; $entry-&gt;formEmailAddress,
            'formPhoneNumber' =&gt; $entry-&gt;formPhoneNumber,
        ]
    );

    if(!$model
        -&gt;addRule(['formGender', 'formFirstName', 'formLastName', 'formEmailAddress'], 'required')
        -&gt;addRule('formGender', 'in', ['range' =&gt; ['male', 'female']])
        -&gt;addRule('formEmailAddress', 'email')
        -&gt;addRule('formPhoneNumber', 'match', ['pattern' =&gt; '/^[0-9]+$/'])
        -&gt;validate()
    ) {
        return [
            'success' =&gt; false,
            'errors' =&gt; $model-&gt;getErrors(),
        ];
    }

    return [
        'success' =&gt; true,
        'errors' =&gt; [],
    ];
    }
}