code: public static function createValidator($type, $model, $attributes, $params = [])
      {
          $params['attributes'] = $attributes;
  
          if ($type instanceof \Closure || ($model->hasMethod($type) && !isset(static::$builtInValidators[$type]))) {
              // method-based validator
              $params['class'] = __NAMESPACE__ . '\InlineValidator';
              $params['method'] = $type;
          } else {
              if (isset(static::$builtInValidators[$type])) {
                  $type = static::$builtInValidators[$type];
              }
              if (is_array($type)) {
                  $params = array_merge($type, $params);
              } else {
                  $params['class'] = $type;
              }
          }
  
          return Yii::createObject($params);
      }
docs: Creates a validator object.
  @param string|\Closure $type the validator type. This can be either:
  * a built-in validator name listed in [[builtInValidators]];
  * a method name of the model class;
  * an anonymous function;
  * a validator class name.
  @param \yii\base\Model $model the data model to be validated.
  @param array|string $attributes list of attributes to be validated. This can be either an array of
  the attribute names or a string of comma-separated attribute names.
  @param array $params initial values to be applied to the validator properties.
  @return Validator the validator