/** * Validates and optionally saves a message log record from an array * * @param array $array Data to be validated and optionally saved * @param bool $save Creates the record in the DB when TRUE * @return bool */ public function validate(array &$array, $save = FALSE) { // Validation rules for a log entry $array = Validation::factory($array)->pre_filter('trim')->add_rules('message_id', 'required')->add_rules('message_sender', 'required')->add_rules('message_type', 'required', 'in_array[0,1]'); // Pass validation to parent and return return parent::validate($array, $save); }
/** * Specify our rules here so that we have access to the instance of this model. */ public function validate($array = null) { if (!$array) { $this->rules = array("name" => array("rules" => array("required", "length[1,32]"), "callbacks" => array(array($this, "valid_name"))), "flat_rate" => array("rules" => array("required", "decimal")), "per_item" => array("rules" => array("required"))); } parent::validate($array); }
public function password_validate(Validation $array, $save = FALSE) { $array->pre_filter('trim'); $array->add_rules('password', 'required', 'length[7,30]', 'matches[password2]'); $this->forgotten_password_key = NULL; return parent::validate($array, $save); }
public function validate(Validation $array, $save = false) { if ($save) { $this->logDeterminations($array); } if (empty($this->submission['fields']['record_status']) && $this->wantToUpdateMetadata) { // If we update an occurrence but don't set the verification state, revert it to // completed/awaiting verification. $array->verified_by_id = null; $array->verified_on = null; $array->record_status = 'C'; } $array->pre_filter('trim'); $array->add_rules('sample_id', 'required'); $array->add_rules('website_id', 'required'); $fieldlist = $array->as_array(); if (!array_key_exists('all_info_in_determinations', $fieldlist) || $fieldlist['all_info_in_determinations'] == 'N') { $array->add_rules('taxa_taxon_list_id', 'required'); } // Explicitly add those fields for which we don't do validation $this->unvalidatedFields = array('comment', 'determiner_id', 'deleted', 'record_status', 'release_status', 'downloaded_flag', 'verified_by_id', 'verified_on', 'confidential', 'all_info_in_determinations', 'external_key', 'zero_abundance', 'last_verification_check_date', 'last_verification_check_taxa_taxon_list_id', 'last_verification_check_version', 'training', 'sensitivity_precision'); if (array_key_exists('id', $fieldlist)) { // existing data must not be set to download_flag=F (final download) otherwise it // is read only $array->add_rules('downloaded_flag', 'chars[N,I]'); } return parent::validate($array, $save); }
/** * Validates and optionally saves a new level record from an array * * @param array $array Values to check * @param save $save Saves the level record when validation succeeds * @return bool */ public function validate(array &$array, $save = FALSE) { // Setup validation $array = Validation::factory($array)->pre_filter('trim')->add_rules('level_title', 'required', 'length[3,80]')->add_rules('level_description', 'required')->add_rules('level_weight', 'required'); // Pass validation to parent and return return parent::validate($array, $save); }
/** * Specify our rules here so that we have access to the instance of this model. */ public function validate($array = null) { if (!$array) { $this->rules = array("name" => array("rules" => array("required", "length[1,32]"), "callbacks" => array(array($this, "valid_name"))), "description" => array("rules" => array("required", "length[0,255]")), "cost" => array("rules" => array("required", "decimal"))); } parent::validate($array); }
/** * Validates and optionally saves a form field record from an array * * @param array $array Values to check * @param bool $save Save the record when validation suceeds * @return bool */ public function validate(array &$array, $save = FALSE) { // Setup validation $array = Validation::factory($array)->pre_filter('trim', TRUE)->add_rules('form_id', 'required', 'numeric', array('Form_Model', 'is_valid_form'))->add_rules('field_type', 'required', 'numeric')->add_rules('field_name', 'required', 'length[1,1000]')->add_rules('field_required', 'required', 'between[0,1]')->add_rules('field_ispublic_visible', 'required', 'numeric')->add_rules('field_ispublic_submit', 'required', 'numeric'); // Get the field type $array->field_isdate = $array->field_type == 3 ? 1 : 0; // Ensure that checkboxes and radio buttons have a default value if ($array->field_type == 5 or $array->field_type == 6 or $array->field_type == 7) { $array->add_rules('field_default', 'required', 'standard_text'); } // Check if field width and height have been specified if (!empty($array->field_width)) { $array->add_rules('field_width', 'between[0,300]'); } if (!empty($array->field_height)) { $array->add_rules('field_height', 'between[0,50]'); } if (!empty($array->field_default)) { $array->add_rules('field_default', 'length[1,10000]'); } // If date field, and default value is not empty, add date validation rules if (!empty($array->field_default) and !empty($array->field_isdate)) { $array->add_rules('field_default', array('valid', 'date_mmddyyyy')); } // Return return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { $array->pre_filter('trim'); $array->add_rules('title', 'required'); $this->unvalidatedFields = array('code', 'abbreviation', 'description', 'category_id', 'deleted'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { $array->pre_filter('trim'); $array->add_rules('term', 'required'); $array->add_rules('language_id', 'required'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { // uses PHP trim() to remove whitespace from beginning and end of all fields before validation $array->pre_filter('trim'); $this->unvalidatedFields = array('user_id', 'website_id', 'site_role_id'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { $array->pre_filter('trim'); $array->add_rules('taxon_group_id', 'required'); $array->add_rules('taxon_list_id', 'required'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { $array->pre_filter('trim'); $array->add_rules('taxon_id', 'required'); $array->add_rules('taxon_designation_id', 'required'); $this->unvalidatedFields = array('start_date', 'source', 'geographical_constraint', 'deleted'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { $array->pre_filter('trim'); $array->add_rules('group_id', 'required'); $array->add_rules('user_id', 'required'); $this->unvalidatedFields = array('administrator', 'deleted', 'pending'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { $array->pre_filter('trim'); $array->add_rules('group_id', 'required'); $array->add_rules('location_id', 'required'); $this->unvalidatedFields = array('deleted'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { // uses PHP trim() to remove whitespace from beginning and end of all fields before validation $array->pre_filter('trim'); $array->add_rules('filter_id', 'required'); $array->add_rules('user_id', 'required'); return parent::validate($array, $save); }
/** * Specify our rules here so that we have access to the instance of this model. */ public function validate(Validation $array = null) { // validate() is recursive, only modify the rules on the outermost call. if (!$array) { $this->rules = array("admin" => array("callbacks" => array(array($this, "valid_admin"))), "email" => array("rules" => array("length[1,255]", "valid::email"), "callbacks" => array(array($this, "valid_email"))), "full_name" => array("rules" => array("length[0,255]")), "locale" => array("rules" => array("length[2,10]")), "name" => array("rules" => array("length[1,32]", "required"), "callbacks" => array(array($this, "valid_name"))), "password" => array("callbacks" => array(array($this, "valid_password"))), "url" => array("rules" => array("valid::url"))); } parent::validate($array); }
public function validate(Validation $array, $save = FALSE) { // uses PHP trim() to remove whitespace from beginning and end of all fields before validation $array->pre_filter('trim'); $array->add_rules('title', 'required', 'length[1,10]'); $this->unvalidatedFields = array('deleted'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = false) { $array->pre_filter('trim'); $array->add_rules('taxon_meaning_id', 'required'); $array->add_rules('path', 'required'); $this->unvalidatedFields = array('caption', 'external_details', 'media_type_id'); return parent::validate($array, $save); }
/** * Specify our rules here so that we have access to the instance of this model. */ public function validate(Validation $array = null) { // validate() is recursive, only modify the rules on the outermost call. if (!$array) { $this->rules = array("name" => array("rules" => array("required", "length[4,255]"), "callbacks" => array(array($this, "valid_name")))); } parent::validate($array); }
/** * Add some custom per-instance rules. */ public function validate(Validation $array = null) { // validate() is recursive, only modify the rules on the outermost call. if (!$array) { $this->rules = array("guest_name" => array("callbacks" => array(array($this, "valid_author"))), "guest_email" => array("callbacks" => array(array($this, "valid_email"))), "guest_url" => array("rules" => array("url")), "item_id" => array("callbacks" => array(array($this, "valid_item"))), "state" => array("rules" => array("Comment_Model::valid_state")), "text" => array("rules" => array("required"))); } parent::validate($array); }
public function validate(Validation $array, $save = FALSE) { // uses PHP trim() to remove whitespace from beginning and end of all fields before validation $array->pre_filter('trim'); $array->add_rules('rank', 'required', 'length[1,50]'); $array->add_rules('short_name', 'required', 'length[1,20]'); $this->unvalidatedFields = array('italicise_taxon', 'sort_order', 'deleted'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = false) { $array->pre_filter('trim'); $array->add_rules('from_taxon_meaning_id', 'required'); $array->add_rules('to_taxon_meaning_id', 'required'); $array->add_rules('taxon_relation_type_id', 'required'); $this->unvalidatedFields = array('deleted'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { $array->pre_filter('trim'); $array->add_rules('association_type_id', 'required'); $array->add_rules('from_occurrence_id', 'required'); $array->add_rules('to_occurrence_id', 'required'); $this->unvalidatedFields = array('part_id', 'position_id', 'impact_id', 'deleted'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { // uses PHP trim() to remove whitespace from beginning and end of all fields before validation $array->pre_filter('trim'); $array->add_rules('comment', 'required'); $array->add_rules('occurrence_id', 'required'); // Explicitly add those fields for which we don't do validation $this->unvalidatedFields = array('email_address', 'person_name', 'deleted', 'auto_generated', 'generated_by', 'implies_manual_check_required', 'query', 'record_status', 'record_substatus'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { // uses PHP trim() to remove whitespace from beginning and end of all fields before validation $array->pre_filter('trim'); $array->add_rules('user_id', 'required'); $values = $array->as_array(); // Explicitly add those fields for which we don't do validation $this->unvalidatedFields = array('survey_id', 'location_id', 'taxon_group_id', 'deleted'); return parent::validate($array, $save); }
public function email_validate(Validation $array, $save = FALSE) { // this function is used when updating the email address through the new_password screen // This would happen on initial login for the admin user - the setup procedure does not include the email address for the // the admin user // uses PHP trim() to remove whitespace from beginning and end of all fields before validation $array->pre_filter('trim'); $array->add_rules('email_address', 'required', 'email', 'length[1,50]', 'unique[people,email_address,' . $array->id . ']'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = false) { // uses PHP trim() to remove whitespace from beginning and end of all fields before validation $array->pre_filter('trim'); $array->add_rules('identifier_type_id', 'required', 'digit'); $array->add_rules('website_id', 'required', 'digit'); // Explicitly add those fields for which we don't do validation $this->unvalidatedFields = array('issue_authority_id', 'issue_scheme_id', 'issue_date', 'first_use_date', 'last_observed_date', 'final_date', 'coded_value', 'summary', 'known_subject_id', 'deleted'); return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { $array->pre_filter('trim'); $array->add_rules('taxon', 'required'); $array->add_rules('language_id', 'required'); $array->add_rules('taxon_group_id', 'required'); // Explicitly add those fields for which we don't do validation $this->unvalidatedFields = array('external_key', 'authority', 'deleted', 'search_code', 'description'); return parent::validate($array, $save); }
/** * Validates and optionally saves a new layer record from an array * * @param array $array Values to check * @param bool $save Saves the record when validation succeeds * @return bool */ public function validate(array &$array, $save = FALSE) { // Set up validation $array = Validation::factory($array)->pre_filter('trim')->add_rules('layer_name', 'required', 'length[3,80]')->add_rules('layer_color', 'required', 'length[6,6]'); // Add callbacks for the layer url and layer file $array->add_callbacks('layer_url', array($this, 'layer_url_file_check')); $array->add_callbacks('layer_file', array($this, 'layer_url_file_check')); // Pass validation to parent and return return parent::validate($array, $save); }
public function validate(Validation $array, $save = FALSE) { if (array_key_exists('validation_rules', $array->as_array())) { $this->validation_rules = $array['validation_rules']; $save = $save && $this->validateValidationRules(); } else { $this->validation_rules = null; } return parent::validate($array, $save); }