/** * Validate a value * @params pdoMap_Mapping_Entity Entity to handle * @params pdoMap_Mapping_Metadata_Field Field to manage * @params mixed Value to handle * @returns boolean True if value is valid or false if not */ public function Validate(pdoMap_Mapping_Entity $entity, pdoMap_Mapping_Metadata_Field $field, $value) { if (!is_string($value)) { return false; } else { return strlen($value) <= $field->getOption('size'); } }
/** * Validate a value * @params pdoMap_Mapping_Entity Entity to handle * @params pdoMap_Mapping_Metadata_Field Field to manage * @params mixed Value to handle * @returns boolean True if value is valid or false if not */ public function Validate(pdoMap_Mapping_Entity $entity, pdoMap_Mapping_Metadata_Field $field, $value) { if (is_numeric($value)) { return true; } elseif ($value instanceof pdoMap_Mapping_Entity) { return $value->getType() == $field->getOption('adapter'); } else { return false; } }
/** * Validate a value * @params pdoMap_Mapping_Entity Entity to handle * @params pdoMap_Mapping_Metadata_Field Field to manage * @params mixed Value to handle * @returns boolean True if value is valid or false if not */ public function Validate(pdoMap_Mapping_Entity $entity, pdoMap_Mapping_Metadata_Field $field, $value) { return in_array($value, $field->getOption('value')); }
/** * Validate a value * @params pdoMap_Mapping_Entity Entity to handle * @params pdoMap_Mapping_Metadata_Field Field to manage * @params mixed Value to handle * @returns boolean True if value is valid or false if not */ public function Validate(pdoMap_Mapping_Entity $entity, pdoMap_Mapping_Metadata_Field $field, $value) { // CHECK TYPE if (!is_int($value)) { return false; } // CHECK SIZE switch ($field->getOption('size')) { case 'tiny': $max = 255; break; case 'small': $max = 65535; break; case 'medium': $max = 16777215; break; case 'normal': $max = 4294967295.0; case 'big': $max = mt_getrandmax(); // biggest value : 18446744073709551615; break; } if ($field->GetOption('unsigned') != 'true') { $min = -$max - 1; $max = ($max - 1) / 2; } else { $min = 0; } return $value >= $min && $value <= $max; }