Skip to content

Validators queryRules maximum results value throwing exception #328

@itwebdeveloper

Description

@itwebdeveloper

Reproduction steps:

  1. Create a Validator.php file for the resourse. E.g. app/JsonApi/Item/Validators.php

  2. Change the queryRules() method to:

    /**
     * @return array
     */
    protected function queryRules(): array
    {
        return [
            'page.number' => 'filled|numeric|min:1',
            'page.size' => 'filled|numeric|between:1,50',
        ];
    }
    
  3. Send a GET request to the resource endpoint with a page.size value greater than the maximum value set in the queryRules(), e.g. http://api.example.test/api/v1/item?page[number]=1&page[size]=51

Result:

CloudCreativity\LaravelJsonApi\Exceptions\ValidationException: JSON API error in file /home/vagrant/code/example-api/vendor/cloudcreativity/laravel-json-api/src/Exceptions/ValidationException.php on line 49

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions