Class Phalcon\Validation\Validator\Date

extends abstract class Phalcon\Validation\Validator

implements Phalcon\Validation\ValidatorInterface

Source on GitHub

Checks if a value is a valid date

  1. <?php
  2. use Phalcon\Validation\Validator\Date as DateValidator;
  3. $validator->add(
  4. "date",
  5. new DateValidator(
  6. [
  7. "format" => "d-m-Y",
  8. "message" => "The date is invalid",
  9. ]
  10. )
  11. );
  12. $validator->add(
  13. [
  14. "date",
  15. "anotherDate",
  16. ],
  17. new DateValidator(
  18. [
  19. "format" => [
  20. "date" => "d-m-Y",
  21. "anotherDate" => "Y-m-d",
  22. ],
  23. "message" => [
  24. "date" => "The date is invalid",
  25. "anotherDate" => "The another date is invalid",
  26. ],
  27. ]
  28. )
  29. );

Methods

public validate (Phalcon\Validation $validation, mixed $field)

Executes the validation

private checkDate (mixed $value, mixed $format)

public __construct ([array $options]) inherited from Phalcon\Validation\Validator

Phalcon\Validation\Validator constructor

public isSetOption (mixed $key) inherited from Phalcon\Validation\Validator

Checks if an option has been defined

public hasOption (mixed $key) inherited from Phalcon\Validation\Validator

Checks if an option is defined

public getOption (mixed $key, [mixed $defaultValue]) inherited from Phalcon\Validation\Validator

Returns an option in the validator’s options Returns null if the option hasn’t set

public setOption (mixed $key, mixed $value) inherited from Phalcon\Validation\Validator

Sets an option in the validator