From ac6c582a37653d1d31d22179fe73308ecb4565ce Mon Sep 17 00:00:00 2001 From: Danny van der Sluijs Date: Tue, 9 Sep 2025 15:07:11 +0200 Subject: [PATCH] docs: Document how custom error messages is being handled --- _docs/advanced-topics.md | 25 +++- _site/advanced-topics.html | 142 -------------------- _site/community-guide.html | 142 -------------------- _site/configuration.html | 142 -------------------- _site/contributors.html | 149 --------------------- _site/docs/advanced-topics.html | 98 ++++++++++++-- _site/docs/check-mode.html | 29 +++-- _site/docs/contributors.html | 12 +- _site/docs/getting-started.html | 8 +- _site/docs/search.html | 224 ++++++++++++++++++++++++++++++++ _site/docs/search.json | 2 +- _site/feed.xml | 2 + _site/getting-started.html | 202 ---------------------------- _site/media/mix-manifest.json | 9 -- 14 files changed, 364 insertions(+), 822 deletions(-) delete mode 100644 _site/advanced-topics.html delete mode 100644 _site/community-guide.html delete mode 100644 _site/configuration.html delete mode 100644 _site/contributors.html create mode 100644 _site/docs/search.html create mode 100644 _site/feed.xml delete mode 100644 _site/getting-started.html delete mode 100644 _site/media/mix-manifest.json diff --git a/_docs/advanced-topics.md b/_docs/advanced-topics.md index f4f8707..310bd6b 100644 --- a/_docs/advanced-topics.md +++ b/_docs/advanced-topics.md @@ -67,4 +67,27 @@ if ($validator->isValid()) { This paragraph needs to be written, want to help out? Checkout GitHub repo! ## Using custom error messages -This paragraph needs to be written, want to help out? Checkout GitHub repo! +All the errors returned from the library contain a unique constraint name. Using this constraint name you can replace the +error message with own, adjusting for your tone of voice or language. + +```php +addSchema('internal://mySchema', $jsonSchema); +$validator = new JsonSchema\Validator( + new JsonSchema\Constraints\Factory($schemaStorage) +); +$validator->validate($data, $jsonSchemaObject); + +foreach ($validator->getErrors() as $error) { + echo sprintf( + customErrorMessagePatternFunction($error['constraint']['name']), + ...$error['constraint']['params'] + ); +} +``` diff --git a/_site/advanced-topics.html b/_site/advanced-topics.html deleted file mode 100644 index 37624f6..0000000 --- a/_site/advanced-topics.html +++ /dev/null @@ -1,142 +0,0 @@ - - - - - -JSON Schema for PHP - Advanced topics - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Skip to content -
-
-
-
-

Advanced topics

-

This page needs to be written, want to help out? Checkout GitHub repo!

- -
-
-
-
- - - - - - - - - - - - - - - - - diff --git a/_site/community-guide.html b/_site/community-guide.html deleted file mode 100644 index e1d8a63..0000000 --- a/_site/community-guide.html +++ /dev/null @@ -1,142 +0,0 @@ - - - - - -JSON Schema for PHP - Community guide - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Skip to content -
-
-
-
-

Community guide

-

This page needs to be written, want to help out? Checkout GitHub repo!

- -
-
-
-
- - - - - - - - - - - - - - - - - diff --git a/_site/configuration.html b/_site/configuration.html deleted file mode 100644 index c6022a3..0000000 --- a/_site/configuration.html +++ /dev/null @@ -1,142 +0,0 @@ - - - - - -JSON Schema for PHP - Configuration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Skip to content -
-
-
-
-

Configuration

-

This page needs to be written, want to help out? Checkout GitHub repo!

- -
-
-
-
- - - - - - - - - - - - - - - - - diff --git a/_site/contributors.html b/_site/contributors.html deleted file mode 100644 index 513c2b3..0000000 --- a/_site/contributors.html +++ /dev/null @@ -1,149 +0,0 @@ - - - - - -JSON Schema for PHP - Contributors - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Skip to content -
-
-
-
-

Contributors

-

JSON Schema for PHP would not exist without the dedication, time, and expertise of our community.
-Every feature, improvement, and bug fix is the result of people generously sharing their skills and ideas.
-We are deeply grateful for each and every contribution — large or small — that has helped shape this project.

-

Check out all the amazing people who have made this possible:

- - - -

Made with contrib.rocks.

- -
-
-
-
- - - - - - - - - - - - - - - - - diff --git a/_site/docs/advanced-topics.html b/_site/docs/advanced-topics.html index d354701..4b0b6f4 100644 --- a/_site/docs/advanced-topics.html +++ b/_site/docs/advanced-topics.html @@ -20,7 +20,7 @@ - + @@ -78,8 +78,8 @@ Getting started