(C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011 (C) OpenEyes Foundation, 2011-2013 This file is part of OpenEyes. OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see .
저자: OpenEyes (info@openeyes.org.uk)
상속: extends CValidator
예제 #1
0
 /**
  * Perform form data validation.
  *
  * @param $form_data
  *
  * @return array
  */
 public function validate($form_data)
 {
     $errs = array();
     if (!@$form_data['appointment_date']) {
         $errs['appointment_date'] = 'Please enter an appointment date';
     }
     $appointment_date = \Helper::convertNHS2MySQL($form_data['appointment_date']);
     $date_validator = new \OEDateValidator();
     if (!$date_validator->validateValue($appointment_date)) {
         if (strtotime($appointment_date) != false) {
             $errs['appointment_date'] = 'Appointment date is not in valid format';
         } else {
             $errs['appointment_date'] = 'Appointment date is not a valid date';
         }
     } else {
         $not_historical_validator = new \OEDateValidatorNotHistorical();
         if ($not_historical_validator->validateValue($appointment_date) == false) {
             $errs['appointment_date'] = 'Appointment date cannot be in the past';
         }
     }
     if ($appointment_time = @$form_data['appointment_time']) {
         $time_validator = new \OETimeValidator();
         if (!$time_validator->validateValue($appointment_time)) {
             $errs['appointment_time'] = 'Appointment time is not valid';
         }
     }
     return $errs;
 }
예제 #2
0
 /**
  * @dataProvider validateValueProvider
  *
  * @param $time
  * @param $valid
  */
 public function test_validateValue($time, $valid)
 {
     $validator = new OETimeValidator();
     $this->assertEquals($valid, $validator->validateValue($time));
 }