/** * @param AbstractField $field * @return bool */ public function isValid(AbstractField $field) { if ($field instanceof CheckboxField) { return $field->getValue(); } return false; }
/** * @param AbstractField $field * @return bool */ public function isValid(AbstractField $field) { $value = $field->getValue(); if (is_string($value)) { $value = trim($value); } return !empty($value); }
/** * @param AbstractField $field * @return \stdClass */ public static function validateField(AbstractField $field) { $errors = array(); $result = new \stdClass(); if ($field->hasRules()) { self::loop($field, $field->getRules(), $errors); } $result->valid = empty($errors); $result->trace = $errors; return $result; }
/** * @param AbstractField $field * @return bool */ public function isValid(AbstractField $field) { $value = $field->getValue(); if ($this->min !== null) { if ($this->inclusive == true && !(strlen($value) >= $this->min) || $this->inclusive == false && !(strlen($value) > $this->min)) { return false; } } if ($this->max !== null) { if ($this->inclusive == true && !(strlen($value) <= $this->max) || $this->inclusive == false && !(strlen($value) < $this->max)) { return false; } } return true; }
/** * {@inheritdoc} */ public function run(AbstractField $field) { return call_user_func_array($this->condition, array($field->getParent()->getData())); }
/** * @param AbstractField $field * @return bool */ public function isValid(AbstractField $field) { $result = $this->client->checkVat(array('countryCode' => (string) $this->countryCode, 'vatNumber' => (int) $field->getValue())); return $result->valid; }
/** * @param AbstractField $field * @return $this */ public function addField(AbstractField $field) { $field->setParent($this); $this->fields[$field->getId()] = $field; return $this; }
/** * @param AbstractField $field * @return bool */ public function isValid(AbstractField $field) { return filter_var($field->getValue(), FILTER_VALIDATE_EMAIL); }
/** * @param AbstractField $field * @return string */ public function renderField(AbstractField $field) { $html = "<div>"; if ($field instanceof \Formjack\Field\CheckboxField) { if ($field->hasLabel()) { $html .= "<label>{$field->render()} {$field->getLabel()}</label>"; } else { $html .= $field->render(); } } elseif ($field instanceof \Formjack\Field\AbstractGroup) { if ($field->hasLabel()) { $html .= "<label>{$field->getLabel()}</label>"; } foreach ($field->getChoices() as $choice => $label) { $html .= "<label>{$field->renderChoice($choice)} {$label}</label>"; } } else { if ($field->hasLabel()) { $html .= "<label>{$field->getLabel()}</label>"; } $html .= $field->render(); } if ($field->hasErrors()) { $html .= "<ul class=\"errors\">"; foreach ($field->getErrors() as $error) { $html .= "<li>{$error}</li>"; } $html .= "</ul>"; } $html .= "</div>"; return $html; }
/** * @param AbstractField $field * @return bool */ public function isValid(AbstractField $field) { return is_numeric($field->getValue()); }