protected function validate($data, $rules = null, $messages = [])
    {
        // A request may be passed in when using Laravel traits, like how resetting
        // passwords work.  Get the input from it
        if (is_a($data, \Illuminate\Http\Request::class)) {
            $data = $data->input();
        }

        // Get validation rules from model
        $model = null;
        if (is_a($data, BaseModel::class)) {
            $model = $data;
            $data = $model->getAttributes();
            if (empty($rules)) {
                $rules = $model::$rules;
            }
        }

        // If an AJAX update, don't require all fields to be present. Pass just the
        // keys of the input to the array_only function to filter the rules list.
        if (Request::ajax() && Request::getMethod() == 'PUT') {
            $rules = array_only($rules, array_keys(request()->input()));
        }

        // Stop if no rules
        if (empty($rules)) {
            return;
        }

        // Build the validation instance and fire the intiating event.
        if ($model) {
            (new ModelValidator)->validate($model, $rules, $messages);
        } else {
            $messages = array_merge(BkwldLibraryValidator::$messages, $messages);
            $validation = Validator::make($data, $rules, $messages);
            if ($validation->fails()) {
                throw new ValidationFail($validation);
            }
        }
    }