OBPIH-5832 Rename pagination and filter command and implement validat…#4495
Conversation
| if (params.hasErrors()) { | ||
| throw new ValidationException("Invalid params", params.errors) | ||
| } |
There was a problem hiding this comment.
Thinking out loud...
My lazy butt is wondering if we should/could/want to create validationInterceptor that handles checking if a command object has errors and throw an exception instead of writing this logic everywhere ourselves.
There was a problem hiding this comment.
I thought the same thing with respect to request.exception (maybe we could handle both cases in the same interceptor). However, something doesn't feel right about this approach so I'd prefer to explore it as part of a separate spike.
| Set<String> usedAliases = new HashSet<>() | ||
|
|
||
| return ProductSupplier.createCriteria().list(max: params.max, offset: params.offset) { | ||
| return ProductSupplier.createCriteria().list(params.getPaginationParams()) { |
|
|
||
|
|
||
| List<ProductSupplier> getProductSuppliers(ProductSupplierListParams params) { | ||
| List<ProductSupplier> getProductSuppliers(ProductSupplierFilterCommand params) { |
There was a problem hiding this comment.
ProductSupplierFilterCommand command
| if (params.hasErrors()) { | ||
| throw new ValidationException("Invalid params", params.errors) | ||
| } |
There was a problem hiding this comment.
I thought the same thing with respect to request.exception (maybe we could handle both cases in the same interceptor). However, something doesn't feel right about this approach so I'd prefer to explore it as part of a separate spike.
#4495) * OBPIH-5832 Rename pagination and filter command and implement validateable interface * OBPIH-5832 Rename params to command
…eable interface
The PR is addressing @jmiranda 's suggestions: #4438 (comment)
Additionally, I've added
implements Validateablefor those commands, so we do not get warnings in the console, even though we do not need any validation for the filter params now.