json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

fix: replace filter_var for uri and uri-reference to userland code to be RFC 3986 compliant

Open DannyvdSluijs opened this issue 7 months ago • 0 comments

This pull request introduces new validators for URI and relative references and integrates them into the FormatConstraint class. The changes also include corresponding unit tests to ensure the validators work as expected.

New Validators:

  • src/JsonSchema/Tool/Validator/UriValidator.php: Added a new class UriValidator to validate URIs according to RFC 3986 and RFC 5322 for mailto: URIs.
  • src/JsonSchema/Tool/Validator/RelativeReferenceValidator.php: Added a new class RelativeReferenceValidator to validate relative references according to RFC 3986.

Integration into FormatConstraint:

  • src/JsonSchema/Constraints/FormatConstraint.php: Integrated the new UriValidator and RelativeReferenceValidator into the check method to replace the previous inline validation logic for uri and uri-reference formats.

Unit Tests:

  • tests/Tool/Validator/UriValidatorTest.php: Added unit tests for UriValidator to ensure it correctly validates valid and invalid URIs.
  • tests/Tool/Validator/RelativeReferenceValidatorTest.php: Added unit tests for RelativeReferenceValidator to ensure it correctly validates valid and invalid relative references.

Closing keywords

fixes https://github.com/jsonrainbow/json-schema/issues/685

DannyvdSluijs avatar Mar 05 '25 20:03 DannyvdSluijs