protected function validateField($input, BaseValidator $rule, $name, $index = null) { if (!$rule->validate($input)) { return $this->container->getWhenFailStrategy()->process($this->container(), $rule, $input, $name, $index); } return ValidatorInterface::CODE_RESUME; }
public function __construct($options = null) { //it's not associative, so this means the options is the list if (array_keys($options) === range(0, count($options) - 1)) { $options = array('list' => $options); } parent::__construct($options); }
/** * Constructor takes a single value and not an array. It will set the 'equals' options * to this value. */ public function __construct($options = null) { //not an array, so we assume $options is the token if (!is_array($options)) { $options = array('token' => $options); } parent::__construct($options); }
/** * Validates provided data for model * * @param array $data * @param string $type * * @throws Exception * * @return bool */ public function validate(array $data, $type = 'create') { $this->validator = Validator::make($data, $this->rules[$type]); $validationResult = $this->validator->passes(); if (!$validationResult) { $this->errors = $this->validator->messages(); } return $validationResult; }
/** * Create * @param \Closure $function * @return Custom * @throws \InvalidArgumentException */ public static function create($function) { $validator = parent::create(); if (!is_callable($function)) { throw new \InvalidArgumentException('Function must be collable'); } $validator->function = $function; return $validator; }
/** * Validates the URI. Uses the {@link \Bumble\Uri\UriParser} to parse the link. If the link is * successfully parsed, it return true, else false. * @param $value The url to parse. * @return True if valid, else false. */ public function isValid($value) { parent::isValid($value); $parser = new \Bumble\Uri\UriParser(); $this->URI = $parser->parse($value); if (!$this->URI) { $this->error(self::INVALID_URI, $value); return false; } if ($this->hasMessages()) { return false; } return true; }
function goods_spec_index_1Validator($sys) { parent::BaseValidator($sys); }
function articles_1Validator($sys) { parent::BaseValidator($sys); }
function goods_memo_1Validator($sys) { parent::BaseValidator($sys); }
function goods_keywords_1Validator($sys) { parent::BaseValidator($sys); }
function goods_lv_price_1Validator($sys) { parent::BaseValidator($sys); }
public function __construct($data) { $this->rules = array('quantity' => 'required|integer|min:1', 'amount' => 'required|numeric|min:0', 'postage' => 'required|numeric|min:0'); parent::__construct($data); }
function sitemaps_1Validator($sys) { parent::BaseValidator($sys); }
public function __construct($data) { $this->rules = array('email' => 'required|email|unique:customers'); parent::__construct($data); }
function tags_1Validator($sys) { parent::BaseValidator($sys); }
function UploadRecord($table, $fields, $guidfield, $idfield, $syncfield, $delimiter = ',', $enclosure = '"') { LogUtils::log_str('UploadRecord Begin'); LogUtils::log_obj(func_get_args()); $server =& $GLOBALS['as_server']; $sys =& $GLOBALS['system']; $db = $sys->database(); $syncitems = array(); $atts = $server->getAttachments(); LogUtils::log_obj($atts); if (count($atts) > 0) { $att = null; foreach ($atts as $attitem) { $att = $attitem; break; } $csvfile = ServerUtils::formalPath(ServerUtils::buildPath(AS_TMP_DIR, 'tmpcsv' . time() . '.txt')); file_put_contents($csvfile, $att['data']); LogUtils::log_str($csvfile); $list = TextUtils::csv2array($csvfile, $fields, $delimiter, $enclosure); unlink($csvfile); $validators = BaseValidator::loadValidators(AS_VALIDATOR_DIR, $table, $sys); $idcolarr = split(',', $idfield); foreach ($list as $row) { LogUtils::log_obj($row); $sync_item = array(); $sync_item['guid'] = ''; $sync_item['id'] = ''; $sync_item['succ'] = false; $sync_item['errmsg'] = ''; $sync_item['syncstate'] = AS_SYNC_ADDED; if (array_key_exists($guidfield, $row)) { $sync_item['guid'] = $row[$guidfield]; } if (array_key_exists($syncfield, $row)) { $sync_item['syncstate'] = $row[$syncfield]; } $idcnd = array(); $idcndstr = ''; foreach ($idcolarr as $idcol) { if (array_key_exists($idcol, $row)) { $idcnd[$idcol] = $row[$idcol]; if (!empty($idcndstr)) { $idcndstr .= ' and '; } $idcndstr .= $idcol . "=" . $db->quote($row[$idcol]); } } $sync_item['id'] = implode(',', $idcnd); LogUtils::log_obj($idcnd); switch ($sync_item['syncstate']) { case AS_SYNC_DELETED: if (count($idcnd) > 0) { if (BaseValidator::runValidateBefore($validators, 'delete', $row)) { $sql = "delete from sdb_{$table} where {$idcndstr}"; LogUtils::log_str($sql); if ($db->exec($sql)) { $sync_item['succ'] = true; BaseValidator::runValidateAfter($validators, 'delete', $row); } } } break; case AS_SYNC_UNCHANGED: case AS_SYNC_MODIFIED: if (count($idcnd) > 0) { $sql = "select * from sdb_{$table} where {$idcndstr}"; LogUtils::log_str($sql); $count = $db->_count($sql); if ($count > 0) { if (BaseValidator::runValidateBefore($validators, 'update', $row)) { $rs = $db->query($sql); $sql = $db->getUpdateSql($rs, $row, true); LogUtils::log_str($sql); if ($sql && $db->exec($sql)) { $sync_item['succ'] = true; BaseValidator::runValidateAfter($validators, 'update', $row); } } } else { if (BaseValidator::runValidateBefore($validators, 'insert', $row)) { $rs = $db->query($sql); $sql = $db->getInsertSQL($rs, $row); LogUtils::log_str($sql); if ($sql && $db->exec($sql)) { if (count($idcnd) == 1) { $sync_item['id'] = $db->lastInsertId(); } $sync_item['succ'] = true; BaseValidator::runValidateAfter($validators, 'insert', $row); } } } } break; case AS_SYNC_ADDED: $count = 0; if (count($idcnd) > 0) { $sql = "select * from sdb_{$table} where {$idcndstr}"; LogUtils::log_str($sql); $count = $db->_count($sql); } if ($count > 0) { if (BaseValidator::runValidateBefore($validators, 'update', $row)) { $rs = $db->query($sql); $sql = $db->getUpdateSql($rs, $row, true); LogUtils::log_str($sql); if ($sql && $db->exec($sql)) { $sync_item['succ'] = true; BaseValidator::runValidateAfter($validators, 'update', $row); } } } else { if (BaseValidator::runValidateBefore($validators, 'insert', $row)) { $sql = "select * from sdb_{$table} where 0=1"; LogUtils::log_str($sql); $rs = $db->query($sql); $sql = $db->getInsertSQL($rs, $row); LogUtils::log_str($sql); if ($sql && $db->exec($sql)) { if (count($idcnd) == 1) { $sync_item['id'] = $db->lastInsertId(); } $sync_item['succ'] = true; BaseValidator::runValidateAfter($validators, 'insert', $row); } } } break; } LogUtils::log_obj($sync_item); $syncitems[] = $sync_item; } } $pack = array('items' => $syncitems); LogUtils::log_str('UploadRecord Return'); return $pack; }
function gimages_1Validator($sys) { parent::BaseValidator($sys); }
function products_1Validator($sys) { parent::BaseValidator($sys); }
function specification_1Validator($sys) { parent::BaseValidator($sys); }
function goods_type_1Validator($sys) { parent::BaseValidator($sys); }
function brand_1Validator($sys) { parent::BaseValidator($sys); }
function spec_values_1Validator($sys) { parent::BaseValidator($sys); }
function member_lv_1Validator($sys) { parent::BaseValidator($sys); }