Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion _docs/advanced-topics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?php

$data = '{"age": "John Doe"}'
$jsonSchemaAsString = ' { "type": "object", "properties": { "age": { "type": "integer" } } } ';
Comment on lines +76 to +77
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

Missing semicolons at the end of these PHP statements. Both lines should end with semicolons to be valid PHP syntax.

Copilot uses AI. Check for mistakes.

$jsonSchema = json_decode($jsonSchemaAsString);
$schemaStorage = new JsonSchema\SchemaStorage();
$schemaStorage->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']
Comment on lines +89 to +90
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

The array access pattern is incorrect. Based on the context and typical error structure, this should likely be $error['constraint'] for the constraint name and the parameters structure needs clarification. The current syntax assumes a nested structure that may not exist.

Copilot uses AI. Check for mistakes.
);
}
```
142 changes: 0 additions & 142 deletions _site/advanced-topics.html

This file was deleted.

142 changes: 0 additions & 142 deletions _site/community-guide.html

This file was deleted.

Loading