bsm/grape-pagy

Not throwing validation error: When max_items set

Closed this issue · 3 comments

In an endpoint, max_items set to 10. It should have to throw the error if endpoint parms contain items value large than max_items

params do
      use :pagy,
          max_items: 10
 end

Expected:

{
    "error": {
        "status": 422,
        "message": "max_items value max can be 10"
    }
}
dim commented

@sanjain-progress the current behaviour is to apply the limit without validation - see https://github.com/bsm/grape-pagy/blob/main/spec/grape/pagy_spec.rb#L35, but it should be easy to weak this to add an extra strict: true option, or so.

dim commented

Actually, that's not true, this is actually standard pagy behaviour (https://github.com/ddnexus/pagy/blob/570358031737122e8b7cb20b215b29fc73fbc807/lib/pagy/extras/items.rb#L23) - i.e. it normalises instead of validating

Thanks, @dim for the response