ICanBoogie
  • Documentation
  • API Reference
  • Validate master
Namespaces
  • ICanBoogie
    • Validate
      • Reader
      • Validation
      • Validator
      • ValidatorProvider
Classes
  • Context
  • Message
  • Render
  • Validation
  • ValidationErrors
Interfaces
  • Reader
  • Validator
  • ValidatorOptions
  • ValidatorProvider
Exceptions
  • ParameterIsMissing
  • ValidationFailed

Class Validation

Validates data against a set of rules.

ICanBoogie\Validate\Validation implements ICanBoogie\Validate\ValidatorOptions
Namespace: ICanBoogie\Validate
Located at Validation.php

Methods summary

public __construct( array $rules, callable $validator_provider = null )

Parameters

$rules
Validation rules.
$validator_provider
public validates( array $rules ) : ICanBoogie\Validate\Validation

Defines validation rules.

Defines validation rules.

Note: The specified rules may override previously defined rules for the same attributes.

Parameters

$rules

Returns

ICanBoogie\Validate\Validation
$this
public validates_with( string $attribute, string $class_or_alias, array $params ) : ICanBoogie\Validate\Validation

Defines validation for an attribute.

Defines validation for an attribute.

Parameters

$attribute
The attribute to validate.
$class_or_alias
The class name or alias of the validator.
$params
The validator parameters and options.

Returns

ICanBoogie\Validate\Validation
$this
public validate( ICanBoogie\Validate\Reader $reader ) : ICanBoogie\Validate\ValidationErrors|array

Validates data.

Validates data.

Parameters

$reader

Returns

ICanBoogie\Validate\ValidationErrors|array

Returns a ICanBoogie\Validate\ValidationErrors instance if there are validation errors, an empty array otherwise.

protected validate_attribute( string $attribute, array $validators, ICanBoogie\Validate\Context $context )

Validates an attribute.

Validates an attribute.

Parameters

$attribute
$validators
$context
public assert( ICanBoogie\Validate\Reader $reader )

Asserts that data is valid.

Asserts that data is valid.

Parameters

$reader

Throws

ICanBoogie\Validate\ValidationFailed
if the validation failed.
protected create_context( ICanBoogie\Validate\Reader $reader ) : ICanBoogie\Validate\Context

Creates a validation context.

Creates a validation context.

Parameters

$reader

Returns

ICanBoogie\Validate\Context
protected should_skip( ICanBoogie\Validate\Context $context ) : boolean

Whether the validator should be skipped.

Whether the validator should be skipped.

Parameters

$context

Returns

boolean
protected should_stop( ICanBoogie\Validate\Context $context ) : boolean

Whether validation for an attribute should stop.

Whether validation for an attribute should stop.

Parameters

$context

Returns

boolean
protected unserialize_validations( string $serialized_validations ) : array

Resolves validations from a string.

Resolves validations from a string.

Parameters

$serialized_validations

Returns

array

An array of key/value pairs where key if the alias of a validator and value its parameters and options.

protected create_validator( string $class_or_alias ) : ICanBoogie\Validate\Validator

Creates a validator.

Creates a validator.

Parameters

$class_or_alias
The class or alias of the validator.

Returns

ICanBoogie\Validate\Validator
protected create_message( string $message, array $args ) : ICanBoogie\Validate\Message

Creates an error message.

Creates an error message.

Parameters

$message
$args

Returns

ICanBoogie\Validate\Message
protected error( ICanBoogie\Validate\Context $context )

Adds an error to the collection.

Adds an error to the collection.

Parameters

$context

Constants summary

SERIALIZED_STOP_ON_ERROR_SUFFIX : string
'!'
SERIALIZED_VALIDATION_SEPARATOR : string
'|'
SERIALIZED_ALIAS_SEPARATOR : string
':'
SERIALIZED_PARAM_SEPARATOR : string
';'

Constants inherited from ICanBoogie\Validate\ValidatorOptions

OPTION_IF, OPTION_MESSAGE, OPTION_STOP_ON_ERROR, OPTION_UNLESS

Properties summary

protected $validations : array
[]
Validate master – Check on GitHub – API documentation generated by ApiGen