API Schemas ValidationService - evansims/openfga-php GitHub Wiki

Service for validating data against schemas. This service encapsulates validation logic, separating it from object construction concerns in SchemaValidator. It provides validation for both complete data structures and individual properties, with detailed error reporting.

Table of Contents


Namespace

OpenFGA\Schemas


Source

View source code


Implements


Related Classes


Methods

hasSchema

public function hasSchema(string $className): bool

Check if a schema is registered for a class.

View source


Parameters

Name Type Description
$className string The class name to check

Returns

bool — True if schema is registered


registerSchema

public function registerSchema(OpenFGA\Schemas\SchemaInterface $schema): self

Register a schema for validation.

View source


Parameters

Name Type Description
$schema SchemaInterface The schema to register

Returns

self — For method chaining


validate

public function validate(mixed $data, string $className): array<string, mixed>

Validate data against a schema. Validates the provided data against the schema for the specified class. This method only validates structure and types, it does not construct objects.

View source


Parameters

Name Type Description
$data mixed The data to validate
$className string The class name whose schema to validate against

Returns

array&lt;string, mixed&gt; — The validated data (may be normalized/cleaned)


validateProperty

public function validateProperty(mixed $value, OpenFGA\Schemas\SchemaPropertyInterface $property, string $path): mixed

Validate a property value against its schema definition.

View source


Parameters

Name Type Description
$value mixed The value to validate
$property SchemaPropertyInterface The property schema
$path string The property path for error reporting

Returns

mixed — The validated value

⚠️ **GitHub.com Fallback** ⚠️