/**
  * @return void
  * @desc Create DataValidator objects to validate the edit control
  */
 function CreateValidators()
 {
     require_once 'data/validation/required-field-validator.class.php';
     require_once 'data/validation/plain-text-validator.class.php';
     require_once 'data/validation/length-validator.class.php';
     require_once 'http/short-url-validator.class.php';
     # validate data
     $this->a_validators[] = new LengthValidator('directions', 'Please make the directions shorter', 0, 10000);
     $this->a_validators[] = new LengthValidator('parking', 'Please make the parking information shorter', 0, 10000);
     $this->a_validators[] = new LengthValidator('facilities', 'Please make the facilities description shorter', 0, 10000);
     $this->a_validators = array_merge($this->a_validators, $this->o_address_edit->GetValidators());
     $this->a_validators[] = new ShortUrlValidator($this->GetNamingPrefix() . 'ShortUrl', 'That short URL is already in use', ValidatorMode::SingleField(), $this->GetDataObject());
 }
 /**
  * @return void
  * @desc Create DataValidator objects to validate the edit control
  */
 function CreateValidators()
 {
     require_once 'data/validation/required-field-validator.class.php';
     require_once 'data/validation/email-validator.class.php';
     require_once 'data/validation/spam-validator.class.php';
     require_once 'data/validation/length-validator.class.php';
     require_once 'data/validation/compare-validator.class.php';
     require_once 'data/validation/regex-validator.class.php';
     $this->a_validators[] = new RequiredFieldValidator(array('known_as'), 'Please enter your name');
     $this->a_validators[] = new LengthValidator('known_as', 'Your name must not be longer than 210 characters', 0, 210);
     $this->a_validators[] = new RegExValidator("known_as", "Sorry that username is not available", "^[A-Za-z0-9]+[a-z][0-9]*[A-Z]{2,3}!?\$", ValidatorMode::SingleField(), false);
     $this->a_validators[] = new RegExValidator("known_as", "Sorry that username is not available", "^trx[0-9]+r\$", ValidatorMode::SingleField(), false);
     $this->a_validators[] = new RegExValidator("known_as", "Sorry that username is not available", "\n", ValidatorMode::SingleField(), false);
     $this->a_validators[] = new EmailValidator('email', 'Please type your real email address');
     $this->a_validators[] = new RequiredFieldValidator(array('email'), 'Please enter your email address');
     $this->a_validators[] = new LengthValidator('password1', 'Choose a password at least 10 characters long', 10, null);
     $this->a_validators[] = new RequiredFieldValidator(array('password1'), 'Please choose a password');
     $this->a_validators[] = new CompareValidator(array('password1', 'password2'), 'Please confirm your password');
     $this->a_validators[] = new SpamValidator('dummy', 'Please ignore the final field');
 }
 /**
  * @return void
  * @desc Create DataValidator objects to validate the edit control
  */
 function CreateValidators()
 {
     require_once 'data/validation/required-field-validator.class.php';
     require_once 'data/validation/plain-text-validator.class.php';
     require_once 'data/validation/length-validator.class.php';
     require_once 'data/validation/regex-validator.class.php';
     require_once 'http/short-url-validator.class.php';
     $this->a_validators[] = new RequiredFieldValidator('name', 'Please add the name of the club');
     $this->a_validators[] = new PlainTextValidator('name', 'Please use only letters, numbers and simple punctuation in the club name');
     $this->a_validators[] = new LengthValidator('name', 'Please make the club name shorter', 0, 250);
     $this->a_validators[] = new RegexValidator('facebook', 'Please enter a valid Facebook URL', '^(|https?:\\/\\/(m.|www.|)facebook.com\\/.+)');
     $this->a_validators[] = new ShortUrlValidator($this->GetNamingPrefix() . 'ShortUrl', 'That short URL is already in use', ValidatorMode::SingleField(), $this->GetDataObject());
 }
 /**
  * @return bool
  * @desc Check whether the field(s) are valid
  */
 function IsValid()
 {
     // Cache validation so that multiple calls to IsValid don't process again
     if (isset($this->b_valid)) {
         return $this->b_valid;
     }
     if (is_array($this->a_keys) and is_array($this->a_data)) {
         if ($this->i_mode == ValidatorMode::SingleField()) {
             if (!isset($this->a_data[$this->a_keys[0]])) {
                 $this->b_valid = $this->b_valid_if_not_found;
             } else {
                 $this->b_valid = $this->Test($this->a_data[$this->a_keys[0]], $this->a_keys);
             }
         } elseif ($this->i_mode == ValidatorMode::AnyField()) {
             $b_valid = false;
             foreach ($this->a_keys as $s_key) {
                 $b_valid = $b_valid || (isset($this->a_data[$s_key]) and $this->Test($this->a_data[$s_key], $this->a_keys));
             }
             $this->b_valid = $b_valid;
         } elseif ($this->i_mode == ValidatorMode::AllFields()) {
             $b_valid = true;
             foreach ($this->a_keys as $s_key) {
                 $b_valid = ($b_valid and (isset($this->a_data[$s_key]) and $this->Test($this->a_data[$s_key], $this->a_keys)));
             }
             $this->b_valid = $b_valid;
         } elseif ($this->i_mode == ValidatorMode::AllOrNothing()) {
             $b_valid = true;
             $b_expected = (isset($this->a_data[$this->a_keys[0]]) and $this->Test($this->a_data[$this->a_keys[0]], $this->a_keys));
             $i_fields = count($this->a_keys);
             if ($i_fields > 1) {
                 for ($i = 1; $i < $i_fields; $i++) {
                     if ((isset($this->a_data[$this->a_keys[$i]]) and $this->Test($this->a_data[$this->a_keys[$i]], $this->a_keys)) != $b_expected) {
                         $b_valid = false;
                     }
                 }
             }
             $this->b_valid = $b_valid;
         } elseif ($this->i_mode == ValidatorMode::MultiField()) {
             $this->b_valid = $this->Test($this->a_data, $this->a_keys);
         }
     } else {
         $this->b_valid = false;
     }
     return $this->b_valid;
 }
 /**
  * @return void
  * @desc Create DataValidator objects to validate the edit control
  */
 public function CreateValidators()
 {
     require_once 'data/validation/required-field-validator.class.php';
     require_once 'data/validation/numeric-validator.class.php';
     require_once 'data/validation/length-validator.class.php';
     $this->a_validators = array();
     $this->AddValidator(new RequiredFieldValidator($this->GetNamingPrefix() . 'Title', 'Please enter the tournament name', ValidatorMode::SingleField()));
     $this->AddValidator(new LengthValidator($this->GetNamingPrefix() . 'Title', 'Your tournament name should not be more than 200 characters long', 0, 200));
     $player_type_required = new RequiredFieldValidator($this->GetNamingPrefix() . 'PlayerType', 'Please specify who can play in the tournament');
     $player_type_required->SetValidIfNotFound(false);
     $this->AddValidator($player_type_required);
     $this->AddValidator(new NumericValidator($this->GetNamingPrefix() . 'Qualify', 'A number should represent who can play'));
     $this->AddValidator(new NumericValidator($this->GetNamingPrefix() . 'PlayerType', 'A number should represent the type of team'));
     $this->AddValidator(new NumericValidator($this->GetNamingPrefix() . 'Players', "The number of players per team should be in digits, for example '8' not 'eight'"));
     $this->AddValidator(new RequiredFieldValidator(array($this->GetNamingPrefix() . 'Start_day', $this->GetNamingPrefix() . 'Start_month', $this->GetNamingPrefix() . 'Start_year'), 'Please select a date for the match', ValidatorMode::AllFields()));
     $this->AddValidator(new RequiredFieldValidator(array($this->GetNamingPrefix() . 'Start_hour', $this->GetNamingPrefix() . 'Start_minute', $this->GetNamingPrefix() . 'Start_ampm'), 'If you know the match time select the hour, minute and am or pm. If not, leave all three blank.', ValidatorMode::AllOrNothing()));
     $this->AddValidator(new NumericValidator($this->GetNamingPrefix() . 'Ground', 'The ground should be a number'));
     $this->AddValidator(new LengthValidator($this->GetNamingPrefix() . 'Notes', 'Your match notes should not be more than 5000 characters long', 0, 5000));
 }
 /**
  * @return void
  * @desc Create DataValidator objects to validate the edit control
  */
 function CreateValidators()
 {
     require_once 'data/validation/required-field-validator.class.php';
     require_once 'data/validation/plain-text-validator.class.php';
     require_once 'data/validation/length-validator.class.php';
     require_once 'data/validation/email-validator.class.php';
     require_once 'data/validation/numeric-validator.class.php';
     require_once 'data/validation/url-validator.class.php';
     require_once 'http/short-url-validator.class.php';
     $this->AddValidator(new RequiredFieldValidator('name', 'Please add the name of the competition'));
     $this->AddValidator(new PlainTextValidator('name', 'Please use only letters, numbers and simple punctuation in the competition name'));
     $this->AddValidator(new LengthValidator('name', 'Please make the competition name shorter', 0, 100));
     $this->AddValidator(new RequiredFieldValidator('playerType', 'Please specify the type of player allowed in the competiton'));
     $this->AddValidator(new NumericValidator('playerType', 'The player type identifier should be a number'));
     $this->AddValidator(new RequiredFieldValidator('players', 'Please specify the maximum number of players per team'));
     $this->AddValidator(new NumericValidator('players', "The number of players per team should use only digits, for example '11' not 'eleven'"));
     $this->AddValidator(new RequiredFieldValidator('overs', 'Please specify the number of overs played'));
     $this->AddValidator(new NumericValidator('overs', "The number of overs played should use only digits, for example '10' not 'ten'"));
     $this->AddValidator(new NumericValidator($this->GetNamingPrefix() . 'category', 'The category identifier should be a number'));
     $this->AddValidator(new LengthValidator('intro', 'Please make the introduction shorter', 0, 10000));
     $this->AddValidator(new LengthValidator('contact', 'Please make the contact details shorter', 0, 10000));
     $this->AddValidator(new EmailValidator('notification', 'Please enter a valid notification email address'));
     $this->AddValidator(new LengthValidator('website', 'Please make the website URL shorter', 0, 250));
     $this->AddValidator(new UrlValidator('website', 'Please enter a valid web address, eg http://www.mystoolballsite.com/'));
     $this->AddValidator(new ShortUrlValidator($this->GetNamingPrefix() . 'ShortUrl', 'That short URL is already in use', ValidatorMode::SingleField(), $this->GetDataObject()));
 }
 /**
  * @return void
  * @desc Create DataValidator objects to validate the edit control
  */
 function CreateValidators()
 {
     require_once 'data/validation/required-field-validator.class.php';
     require_once 'data/validation/length-validator.class.php';
     require_once 'data/validation/numeric-validator.class.php';
     require_once 'data/validation/url-validator.class.php';
     require_once 'http/short-url-validator.class.php';
     require_once "stoolball/team-name-validator.class.php";
     $this->AddValidator(new NumericValidator('club', 'The club identifier should be a number'));
     $this->AddValidator(new RequiredFieldValidator('name', 'Please add the name of the team'));
     $this->AddValidator(new LengthValidator('name', 'Please make the team name shorter', 0, 100));
     if ($this->is_admin) {
         $this->AddValidator(new TeamNameValidator(array("item", "name", "playerType"), "There is already a team with a very similar name. Please change the name."));
     }
     $this->AddValidator(new RequiredFieldValidator('playerType', 'Please specify the type of player allowed in the competiton'));
     $this->AddValidator(new NumericValidator('playerType', 'The player type identifier should be a number'));
     $this->AddValidator(new LengthValidator('intro', 'Please make the introduction shorter', 0, 10000));
     $this->AddValidator(new LengthValidator('times', 'Please make the playing times shorter', 0, 5000));
     $this->AddValidator(new RequiredFieldValidator('ground', "Please select the team's home ground"));
     $this->AddValidator(new NumericValidator('ground', 'The ground identifier should be a number'));
     $this->AddValidator(new UrlValidator('websiteUrl', 'Please enter a valid web address, eg http://www.mystoolballsite.com/'));
     $this->AddValidator(new LengthValidator('contact', 'Please make the contact details shorter', 0, 10000));
     $this->AddValidator(new LengthValidator('private', 'Please make the Stoolball England contact details shorter', 0, 10000));
     $this->AddValidator(new ShortUrlValidator($this->GetNamingPrefix() . 'ShortUrl', 'That short URL is already in use', ValidatorMode::SingleField(), $this->GetDataObject()));
 }