final public function validate(array $data, $rules, string $type = null)
    {
        try {
            $this->setMessages($rules);
        } catch (\TypeError $e) {
        }
        try {
            $this->setCustomAttributes($rules);
        } catch (\TypeError $e) {
        }

        try {
            $validator = app('validator')->make(
                array_filter($data),
                $rules->getRules($type),
                $this->messages,
                $this->customAttributes
            );

            $this->validating($validator, $rules, $type);
        } catch (\TypeError $e) {
        }

        if (isset($validator) && $validator->fails()) {
            throw new ValidationException($validator);
        }
    }