fork download
  1. <?php
  2.  
  3. class EditFormValidator extends FormValidator
  4. {
  5. public function validate(EditForm $form)
  6. {
  7. $errors = [];
  8. $errors = array_merge(parent::validate($form), $errors);
  9. $errors["accessPass"] = $this->checkAccessPass($form->getAccessPass());
  10. $errors["delPass"] = $this->checkDelPass($form->getDelPass());
  11. $errors = parent::filterErrors($errors);
  12. return $errors;
  13. }
  14.  
  15. public function checkAccessPass($accessPass)
  16. {
  17. return $this->checkPass($accessPass);
  18. }
  19.  
  20. public function checkDelPass($delPass)
  21. {
  22. return $this->checkPass($delPass);
  23. }
  24.  
  25. public function getHtml5RegexForAccessPass()
  26. {
  27. return $this->getHtml5RegexForPass();
  28. }
  29.  
  30. public function getHtml5RegexForDelPass()
  31. {
  32. return $this->getHtml5RegexForPass();
  33. }
  34.  
  35. public function getHintForAccessPass()
  36. {
  37. return $this->getHintForPass();
  38. }
  39.  
  40. public function getHintForDelPass()
  41. {
  42. return $this->getHintForPass();
  43. }
  44.  
  45. private function getHintForPass()
  46. {
  47. $hint = "Пароль должен состоять из цифр и латинских букв. " .
  48. "Длина не должна быть меньше 6 или превышать 20 символов.";
  49. return $hint;
  50. }
  51.  
  52. private function getHtml5RegexForPass()
  53. {
  54. return "^([a-zA-Z\\d]){6,20}$";
  55. }
  56.  
  57. private function checkPass($pass)
  58. {
  59. if (is_null($pass) ||
  60. preg_match("/^([a-z\\d]){6,20}$/ui", $pass)
  61. ) {
  62. $status = true;
  63. } else {
  64. $status = $this->getHintForPass();
  65. }
  66. return $status;
  67. }
  68. }
Runtime error #stdin #stdout #stderr 0s 82880KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Class 'FormValidator' not found in /home/8HJqsF/prog.php on line 3