Skip to content

Validate RM requirements on POST and PUT using lyo-validation - #614

Open
berezovskyi wants to merge 2 commits into
mainfrom
berezovskyi/add-rm-requirement-validation-on-post-put-using
Open

berezovskyi wants to merge 2 commits into
mainfrom
berezovskyi/add-rm-requirement-validation-on-post-put-using

Conversation

@berezovskyi

Copy link
Copy Markdown
Member

Summary

  • Validate RM Requirement POST/PUT resources with lyo-validation before storage, indexing, timestamps, or TRS notifications.
  • Return a generic ValidatedResource containing the resource, validation status, and raw Lyo report; format summary messages lazily.
  • Keep HTTP 400 handling in a separate throwBadRequestIfInvalid helper.
  • Document the required title and identifier and add 12 tests covering validation results, lazy summaries, successful writes, and rejection without side effects.

Closes #179

Testing

  • Passed: cd src && mvn test -pl server-rm -am -Denforcer.skip=true (12 RM tests).
  • Passed: full reactor mvn test -Denforcer.skip=true before the final summary-method refactor; targeted tests rerun after it.
  • Normal mvn test is blocked by an existing SLF4J upper-bound conflict (slf4j-api 2.0.19 vs slf4j-simple 2.0.20); no unrelated dependency changes included.
  • Docker-dependent acceptance tests not run.

@github-actions
github-actions Bot force-pushed the berezovskyi/add-rm-requirement-validation-on-post-put-using branch from 7671a69 to f52f948 Compare October 20, 2026 12:55
import org.eclipse.lyo.shacl.ValidationReport;

/** A validation result; the report is absent when the resource itself is null. */
public record ValidatedResource<T extends AbstractResource>(T resource, boolean valid, ValidationReport report) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Candidate for upstreaming to lyo-validation

import org.eclipse.lyo.shacl.ValidationReport;
import org.eclipse.lyo.validation.ValidatorFactory;

public final class RequirementValidation {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Candidate for upstreaming to lyo-server-common or other server capability. Also good to consider a Jakarta prodivider for ValidatedResource<T> where a REST handler method does not need to do validation manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add RM Requirement validation on POST/PUT using lyo-validation

1 participant