CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • RulesProvider
  • Validation
  • ValidationRule
  • ValidationSet
  • Validator

Interfaces

  • ValidatableInterface
  • ValidatorAwareInterface

Traits

  • ValidatorAwareTrait

Class ValidationRule

ValidationRule object. Represents a validation method, error message and rules for applying such method to a field.

Namespace: Cake\Validation
Location: Validation/ValidationRule.php

Properties summary

  • $_last protected
    boolean
    The 'last' key
  • $_message protected
    string
    The 'message' key
  • $_on protected
    string
    The 'on' key
  • $_pass protected
    array
    Extra arguments to be passed to the validation method
  • $_provider protected
    string

    Key under which the object or class where the method to be used for validation will be found

  • $_rule protected
    string|callable
    The method to be called for a given scope

Method Summary

  • __construct() public
    Constructor
  • _addValidatorProps() protected
    Sets the rule properties from the rule entry in validate
  • _skip() protected
    Checks if the validation rule should be skipped
  • get() public
    Returns the value of a property by name
  • isLast() public

    Returns whether this rule should break validation process for associated field after it fails

  • process() public

    Dispatches the validation rule to the given validator method and returns a boolean indicating whether the rule passed or not. If a string is returned it is assumed that the rule failed and the error message was given as a result.

Method Detail

__construct() public ¶

__construct( array $validator = [] )

Constructor

Parameters
array $validator optional []
[optional] The validator properties

_addValidatorProps() protected ¶

_addValidatorProps( array $validator = [] )

Sets the rule properties from the rule entry in validate

Parameters
array $validator optional []
[optional]

_skip() protected ¶

_skip( array $context )

Checks if the validation rule should be skipped

Parameters
array $context

A key value list of data that could be used as context during validation. Recognized keys are: - newRecord: (boolean) whether or not the data to be validated belongs to a new record - data: The full data that was passed to the validation process - providers associative array with objects or class names that will be passed as the last argument for the validation method

Returns
boolean
True if the ValidationRule should be skipped

get() public ¶

get( string $property )

Returns the value of a property by name

Parameters
string $property
The name of the property to retrieve.
Returns
mixed

isLast() public ¶

isLast( )

Returns whether this rule should break validation process for associated field after it fails

Returns
boolean

process() public ¶

process( mixed $value , array $providers , array $context = [] )

Dispatches the validation rule to the given validator method and returns a boolean indicating whether the rule passed or not. If a string is returned it is assumed that the rule failed and the error message was given as a result.

Parameters
mixed $value
The data to validate
array $providers

associative array with objects or class names that will be passed as the last argument for the validation method

array $context optional []

A key value list of data that could be used as context during validation. Recognized keys are: - newRecord: (boolean) whether or not the data to be validated belongs to a new record - data: The full data that was passed to the validation process - field: The name of the field that is being processed

Returns
boolean|string
Throws
InvalidArgumentException

when the supplied rule is not a valid callable for the configured scope


Properties detail

$_last ¶

protected boolean

The 'last' key

false

$_message ¶

protected string

The 'message' key

$_on ¶

protected string

The 'on' key

$_pass ¶

protected array

Extra arguments to be passed to the validation method

[]

$_provider ¶

protected string

Key under which the object or class where the method to be used for validation will be found

'default'

$_rule ¶

protected string|callable

The method to be called for a given scope

Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs