public function setValidator($name, Validator $validator)
    {
        $validator->setProvider(self::VALIDATOR_PROVIDER_NAME, $this);
        $this->_validators[$name] = $validator;

        return $this;
    }
public function setValidator($name, Validator $validator)
    {
        $validator->setProvider(self::VALIDATOR_PROVIDER_NAME, $this);
        $this->_validators[$name] = $validator;

        return $this;
    }
public function setValidator ( $ name , Validator $ validator ) { $ validator -> setProvider ( self :: VALIDATOR_PROVIDER_NAME , $ this ) ; $ this -> _validators [ $ name ] = $ validator ; return $ this ; }
This method stores a custom validator under the given name.

You can build the object by yourself and store it in your object:

```
$validator = new \Cake\Validation\Validator($table);
$validator
->add('email', 'valid-email', ['rule' => 'email'])
->add('password', 'valid', ['rule' => 'notBlank'])
->allowEmpty('bio');
$this->setValidator('forSubscription', $validator);
```

@param string $name The name of a validator to be set.
@param \Cake\Validation\Validator $validator Validator object to be set.
@return $this
This method stores a custom validator under the given name .