Skip to content

Commit

Permalink
Expose an easy way to override validation options for ActionArgumentB…
Browse files Browse the repository at this point in the history
…uilder (#841)

Co-authored-by: Karthik Ramgopal <[email protected]>
  • Loading branch information
karthikrg and li-kramgopa authored Sep 20, 2022
1 parent 7a82630 commit 26f2a02
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and what APIs have changed, if applicable.

## [Unreleased]

## [29.39.1] - 2022-09-20
Expose an easy way to override validation options for ActionArgumentBuilder

## [29.39.0] - 2022-09-19
Releasing support for UDS in HTTP/2 stack

Expand Down Expand Up @@ -5346,7 +5349,8 @@ patch operations can re-use these classes for generating patch messages.

## [0.14.1]

[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.39.0...master
[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.39.1...master
[29.39.1]: https://github.com/linkedin/rest.li/compare/v29.39.0...v29.39.1
[29.39.0]: https://github.com/linkedin/rest.li/compare/v29.38.6...v29.39.0
[29.38.6]: https://github.com/linkedin/rest.li/compare/v29.38.5...v29.38.6
[29.38.5]: https://github.com/linkedin/rest.li/compare/v29.38.4...v29.38.5
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=29.39.0
version=29.39.1
group=com.linkedin.pegasus
org.gradle.configureondemand=true
org.gradle.parallel=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,17 @@ public RestLiRequestData extractRequestData(RoutingResult routingResult, DataMap
}
DynamicRecordTemplate template = new DynamicRecordTemplate(data, resourceMethodDescriptor.getRequestDataSchema());
ValidationResult result =
ValidateDataAgainstSchema.validate(data, template.schema(), new ValidationOptions(RequiredMode.IGNORE,
CoercionMode.NORMAL));
ValidateDataAgainstSchema.validate(data, template.schema(), getValidationOptions());
if (!result.isValid())
{
throw new RoutingException("Parameters of method '" + resourceMethodDescriptor.getActionName()
+ "' failed validation with error '" + result.getMessages() + "'", HttpStatus.S_400_BAD_REQUEST.getCode());
}
return new RestLiRequestDataImpl.Builder().entity(template).build();
}

protected ValidationOptions getValidationOptions()
{
return new ValidationOptions(RequiredMode.IGNORE, CoercionMode.NORMAL);
}
}

0 comments on commit 26f2a02

Please sign in to comment.