CRUDUI PHP API

Validator
in package

FinalYes

Compose specifications and validate submitted data or list declarations.

Table of Contents

Methods

validate()  : stdClass
Return the validation result object { valid, errors, hidden }, where hidden lists the data paths of the fields that design.show hides. Invalid input text raises ComposeLoadError in the specification and files and FormInputError elsewhere, before any other check. Root data that is a non-empty list raises FormInputError before composition; composition failures raise ComposeLoadError; group or repeated data with the wrong shape raises FormInputError.
validateDetail()  : stdClass
Validate detail composition and metadata without validating record data: the root and the `fields` map of a detail compose, and a forbidden member fails.
validateList()  : stdClass
Validate list composition and metadata without validating row data: the root, the `columns` map and the `search` form-spec reference of a list compose, and a forbidden member fails.
checkText()  : void
Check the text and the limits of a specification, its files, the named inputs and the base path option (docs/spec/input-text.md).
composeMap()  : void
Expand an object map member with properties composition.
composeRoot()  : array<string, mixed>
Compose a list or detail root: `$ref` replaces the members before it, later own members override the base and `$patch` applies last.
declaresComposition()  : bool
Whether a member is an object that declares `$ref` or `$patch`.
loader()  : MemoryLoader
validateComposition()  : stdClass
Compose the root of a specification and the object maps that `$maps` names, then scan the result for forbidden members. A composition failure throws.

Methods

validate()

Return the validation result object { valid, errors, hidden }, where hidden lists the data paths of the fields that design.show hides. Invalid input text raises ComposeLoadError in the specification and files and FormInputError elsewhere, before any other check. Root data that is a non-empty list raises FormInputError before composition; composition failures raise ComposeLoadError; group or repeated data with the wrong shape raises FormInputError.

public static validate(array<string|int, mixed>|stdClass $spec, array<string|int, mixed>|stdClass $data[, array<string|int, mixed> $options = [] ]) : stdClass
Parameters
$spec : array<string|int, mixed>|stdClass
$data : array<string|int, mixed>|stdClass
$options : array<string|int, mixed> = []
Return values
stdClass

validateDetail()

Validate detail composition and metadata without validating record data: the root and the `fields` map of a detail compose, and a forbidden member fails.

public static validateDetail(array<string|int, mixed>|stdClass $spec[, array<string|int, mixed> $options = [] ]) : stdClass
Parameters
$spec : array<string|int, mixed>|stdClass
$options : array<string|int, mixed> = []
Return values
stdClass

validateList()

Validate list composition and metadata without validating row data: the root, the `columns` map and the `search` form-spec reference of a list compose, and a forbidden member fails.

public static validateList(array<string|int, mixed>|stdClass $spec[, array<string|int, mixed> $options = [] ]) : stdClass
Parameters
$spec : array<string|int, mixed>|stdClass
$options : array<string|int, mixed> = []
Return values
stdClass

checkText()

Check the text and the limits of a specification, its files, the named inputs and the base path option (docs/spec/input-text.md).

private static checkText(array<string|int, mixed>|stdClass $spec, array<string|int, mixed> $options, array<int, array{0: string, 1: mixed}> $inputs) : void
Parameters
$spec : array<string|int, mixed>|stdClass
$options : array<string|int, mixed>
$inputs : array<int, array{0: string, 1: mixed}>

composeMap()

Expand an object map member with properties composition.

private static composeMap(array<string|int, mixed> &$composed, string $key, MemoryLoader $loader, string $basepath) : void
Parameters
$composed : array<string|int, mixed>
$key : string
$loader : MemoryLoader
$basepath : string

composeRoot()

Compose a list or detail root: `$ref` replaces the members before it, later own members override the base and `$patch` applies last.

private static composeRoot(array<string|int, mixed>|stdClass $spec, MemoryLoader $loader, string $basepath) : array<string, mixed>
Parameters
$spec : array<string|int, mixed>|stdClass
$loader : MemoryLoader
$basepath : string
Return values
array<string, mixed>

declaresComposition()

Whether a member is an object that declares `$ref` or `$patch`.

private static declaresComposition(mixed $member) : bool
Parameters
$member : mixed
Return values
bool

validateComposition()

Compose the root of a specification and the object maps that `$maps` names, then scan the result for forbidden members. A composition failure throws.

private static validateComposition(array<string|int, mixed>|stdClass $spec, array<string|int, mixed> $options, array<string, bool> $maps) : stdClass
Parameters
$spec : array<string|int, mixed>|stdClass
$options : array<string|int, mixed>
$maps : array<string, bool>

the object maps to compose; true composes a map only when it declares $ref or $patch

Return values
stdClass
On this page

Search results