function testNotEqualTo() { $validator = new CompExpValidator(); $this->assertTrue($validator->validate("30", " ! = 31")); $this->assertFalse($validator->validate("15", "!= 15.0")); try { $this->assertFalse($validator->validate("15", "!= 15.0i")); } catch (Exception $e) { $this->pass(); } }
public function serializeToDojoAsArray() { $regExpValidator = new RegExpValidator(); $compExpValidator = new CompExpValidator(); $constraintParams = array(); $dojoParams = array(); if (!is_array($this->criteria_arr)) { //something is wrong... should never hit this case } //make sure we're starting from beginning of array reset($this->criteria_arr); while (list($key, $crit) = each($this->criteria_arr)) { switch ($this->type_arr[$key]) { case __EZV_REGEXP: $name = $this->getDojoName($key); $value = $this->getDojoValue($key); $dojoParams[$name] = $value; break; case __EZV_COMPEXP: $constraintParams[] = $compExpValidator->getDojoConstraint($crit); break; case __EZV_DATE: case __EZV_CURRENCY: //should never happen... //throw new Error("Cannot handle date or currency types at this time"); //return false; break; case __EZV_UNKNOWN: default: //should never happen... //throw new Error("Cannot determine type"); //return false; break; } } //if we've made it here, check passed constraint_params if (count($constraintParams) > 0) { $dojoParams['constraints'] = '{' . join(",", $constraintParams) . '}'; } //check for dojo "required" constraints if (!$this->getDataCanBeNull() && !$this->getDataCanBeEmpty()) { $dojoParams['required'] = 'true'; } //if we've made it here, this data has passed! return $dojoParams; }