public function validate($attributeNames = null, $clearErrors = true)
    {
        if ($clearErrors) {
            $this->clearErrors();
        }

        if (!$this->beforeValidate()) {
            return reject(new ValidationError("Before validate error"));
        }

        $scenarios = $this->scenarios();
        $scenario = $this->getScenario();
        if (!isset($scenarios[$scenario])) {
            throw new InvalidArgumentException("Unknown scenario: $scenario");
        }

        if ($attributeNames === null) {
            $attributeNames = $this->activeAttributes();
        }

        $attributeNames = (array)$attributeNames;

        $validationPromises = [];
        foreach ($this->getActiveValidators() as $validator) {
            $validationPromises[] = $validator->validateAttributes($this, $attributeNames);
        }
        return Reaction\Promise\allInOrder($validationPromises)
            ->always(function() {
                $this->afterValidate();
            })->then(function() {
                return !$this->hasErrors() ? true : reject(new ValidationError("Validation error"));
            });
    }