Skip to content

Commit

Permalink
docs: Update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tymondesigns committed Jan 15, 2025
1 parent 1707a9a commit f20a682
Showing 1 changed file with 4 additions and 35 deletions.
39 changes: 4 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ $schema->toArray();

// Convert to JSON string
$schema->toJson();
$schema->toJson(JSON_PRETTY_PRINT);

$data = [
'name' => 'John Doe',
'email' => '[email protected]',
'email' => 'foo', // invalid email
'age' => 16,
'active' => true,
'settings' => [
Expand All @@ -97,7 +98,7 @@ try {
}

// Or just get a boolean
$schema->isValid($data);
$schema->isValid($data); // false
```

## Available Schema Types
Expand Down Expand Up @@ -453,40 +454,8 @@ $schema

## Converting to JSON Schema

You can convert any schema to a JSON Schema array or JSON string:

```php
// Convert to array
$jsonSchemaArray = $schema->toArray();

// Convert to JSON string
$jsonSchemaString = $schema->toJson();
$jsonSchemaString = $schema->toJson(JSON_PRETTY_PRINT);
```

This will output a valid JSON Schema that can be used with any JSON Schema validator.
TODO

Example JSON output:
```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": "user",
"description": "User schema",
"required": ["name", "email"],
"properties": {
"name": {
"type": "string",
"minLength": 2,
"maxLength": 100
},
"email": {
"type": "string",
"format": "email"
}
}
}
```

## Credits

Expand Down

0 comments on commit f20a682

Please sign in to comment.