A validator can be either an object of a class extending \craft\commerce\models\Validator, or a model class method
(called inline validator) that has the following signature:

// $params refers to validation parameters given in the rulefunctionvalidatorName($attribute,$params)

In the above $attribute refers to the attribute currently being validated while $params contains an array of
validator configuration options such as max in case of string validator. The value of the attribute currently being validated
can be accessed as $this->$attribute. Note the $ before attribute; this is taking the value of the variable
$attribute and using it as the name of the property to access.

Yii also provides a set of \craft\commerce\models\Validator::builtInValidators.
Each one has an alias name which can be used when specifying a validation rule.

Below are some examples:

[// built-in "required" validator[['username','password'],'required'],// built-in "string" validator customized with "min" and "max" properties['username','string','min'=>3,'max'=>12],// built-in "compare" validator that is used in "register" scenario only['password','compare','compareAttribute'=>'password2','on'=>'register'],// an inline validator defined via the "authenticate()" method in the model class['password','authenticate','on'=>'login'],// a validator of class "DateRangeValidator"['dateRange','DateRangeValidator'],];

Note, in order to inherit rules defined in the parent class, a child class needs to
merge the parent rules with child rules using functions such as array_merge().