验证

@param string $field
@param array $data
@return bool|string
338573
public function validator($field, array $data)
    {
        $value = isset($data[$field]) ? $data[$field] : null;
        if ($value === '' || $value === null) {
            return $this->allowEmpty ? true : $this->message('{fieldName}不是整数！', [
                '{fieldName}' => $this->getName($field),
            ], 'emptyMsg');
        }

        if ($this->min !== null && $this->min > $value) {
            return $this->message('{fieldName}不能小于{min}！', [
                '{fieldName}' => $this->getName($field),
                '{min}' => $this->min,
            ], 'tooSmall');
        }

        if ($this->max !== null && $this->max < $value) {
            return $this->message('{fieldName}不能大于{max}！', [
                '{fieldName}' => $this->getName($field),
                '{max}' => $this->max,
            ], 'tooBig');
        }

        if (!preg_match($this->intOnly ? $this->intPattern : $this->numberPattern, $value)) {
            return $this->message('{fieldName}不是' . ($this->intOnly ? '整数' : '数字') . '！', [
                '{fieldName}' => $this->getName($field),
            ]);
        }

        return true;
    }
1161893
public function set(string $field, string $key, $data, int $expire = self::EXPIRE): bool
    {
        // 缓存数据
        $this->doSet($key, $data, $expire);

        //记录调试信息
        self::debugSet($field . ':' . $key, $data);

        // 取出此表已经缓存的所有键
        $keys = $this->get(self::PREFIX_FIELD . $field);
        if (!$keys or $keys == CacheFactory::NOT_FOUND) {
            $keys = [];
        }

        // 增加一个键,并保存回去,以便以后统一清除
        $keys[] = $key;
        return $this->doSet(self::PREFIX_FIELD . $field, $keys, $expire);
    }
419629
private function isValidateArray($field) {
		
		if(true === isset($this -> validateAsArray[$field])) {
			return $this -> validateAsArray[$field];
		}

		return false;
	}
639641
public function cast($field = null, $data = [], $options = [])
    {
        $defaults = [
            'parent'    => null,
            'basePath'  => null,
            'exists'    => null,
            'defaults'  => true
        ];
        $options += $defaults;

        $options['class'] = $this->reference();

        if ($field !== null) {
            $name = $options['basePath'] ? $options['basePath'] . '.' . $field : (string) $field;
        } else {
            $name = $options['basePath'];
        }

        if ($name === null) {
            return $this->_cast($name, $data, $options);
        }

        foreach([$name, preg_replace('~[^.]*$~', '*', $name, 1)] as $entry) {
            if (isset($this->_relations[$entry])) {
                return $this->_relationCast($field, $entry, $data, $options);
            }
            if (isset($this->_columns[$entry])) {
                return $this->_columnCast($field, $entry, $data, $options);
            }
        }

        if ($this->locked()) {
            return $data;
        }

        if (is_array($data)) {
            $options['class'] = Document::class;
            $options['basePath'] = $name;

            if (isset($data[0])) {
                return $this->_castArray($name, $data, $options);
            } else {
                return $this->_cast($name, $data, $options);
            }
        }

        return $data;
    }
175035
private function getFileIdsByField(array $data, string $field) : array
    {
        $result = Hash::extract($data, sprintf('%s.%s_ids', $this->table->getAlias(), $field));
        $result = empty($result) ? Hash::extract($data, sprintf('%s_ids', $field)) : $result;
        $result = array_filter((array)$result);

        return $result;
    }
420231
private function getFieldData($field)
    {
        if (!isset($this->_fieldData[$field])) {
            foreach ($this->fields as $f) {
                if (($f['key'] === $field) || ($f['name'] === $field)) {
                    $this->_fieldData[$field] = $f;
                    break;
                }
            }
        }

        if (isset($this->_fieldData[$field])) {
            return $this->_fieldData[$field];
        } else {
            throw new Exception("Field $field does not exist");
        }
    }
394272
public function getFieldType($field) {
    try {
      $key = $this->getKey($field);
      
      // dies kann auch einen verschachtelten Array von Types zurück geben, wenn der Schlüssel den man angibt noch Untertypen hat
      return $this->types->get($key, DataInput::THROW_EXCEPTION, DataInput::THROW_EXCEPTION);
    
    } catch (\Psc\DataInputException $e) {
      $e = new FieldNotDefinedException(sprintf("Feld mit den Schluessel(n) '%s' ist nicht in Meta definiert. Vorhanden sind (Ebenen durch . getrennt): %s",
                                                $key, implode(', ', $avFields = $this->getKeys())),
                                        0, $e);
      $e->field = explode(':',$key); // expand
      $e->avaibleFields = $avFields;
      throw $e;
    }
  }
643566
protected function getBlobFields(&$data,$field='') {
        if(!empty($this->blobFields)) {
            $pk =   $this->getPk();
            $id =   $data[$pk];
            if(empty($field)) {
                foreach ($this->blobFields as $field){
                    $identify   =   $this->name.'/'.$id.'_'.$field;
                    $data[$field]   =   F($identify);
                }
                return $data;
            }else{
                $identify   =   $this->name.'/'.$id.'_'.$field;
                return F($identify);
            }
        }
    }
696102
public function data($field, $value = null)
    {
        if (is_array($field)) {
            $this->options['data'] = isset($this->options['data']) ? array_merge($this->options['data'], $field) : $field;
        } else {
            $this->options['data'][$field] = $value;
        }

        return $this;
    }
1357842
public static function finagleVarcharFieldTypeForIndexListing($field, $data) {
   	if (empty($field['persist_wash'])) {
            return $data;
        }
    
        if (strtolower($field['persist_wash']) == "url") {
            $prefacedURL = self::prefaceURLwithHTTP($data);
            return '<a href="'.$prefacedURL.'" target="_blank">'.$data.'</a>';
        }

        return $data;
    }
663675
function(data, name, $field, $el, field, callback) {
      data[name] = $field.val();
      if (field.required && !data[name].length) {
        return apos.afterYield(_.partial(callback, 'required'));
      }
      if (field.max && (data[name].length > field.max)) {
        var $fieldset = self.findFieldset($el, name);
        $fieldset.addClass('apos-error-max');
        return apos.afterYield(_.partial(callback, 'max'));
      }
      return apos.afterYield(callback);
    }
140418
function define_field($data) {
        $this->field->type        = $this->type;
        $this->field->dataid      = $this->data->id;

        $this->field->name        = trim($data->name);
        $this->field->description = trim($data->description);
        $this->field->required    = !empty($data->required) ? 1 : 0;

        if (isset($data->param1)) {
            $this->field->param1 = trim($data->param1);
        }
        if (isset($data->param2)) {
            $this->field->param2 = trim($data->param2);
        }
        if (isset($data->param3)) {
            $this->field->param3 = trim($data->param3);
        }
        if (isset($data->param4)) {
            $this->field->param4 = trim($data->param4);
        }
        if (isset($data->param5)) {
            $this->field->param5 = trim($data->param5);
        }

        return true;
    }
1287623
protected function get($field)
    {
        if (isset($this->raw[$field])) {
            return $this->raw[$field];
        }
        if (preg_match('/^is_/', $field)) {
            return false;
        }

        return null;
    }
885128
public function deserialize($data, Field $field, array $options = [])
    {
        if (!in_array(Options::REFRESH_UUID, $options)) {
            $this->sipe('id', 'setUuid', $data, $field);
        }

        $this->sipe('label', 'setName', $data, $field);
        $this->sipe('type', 'setType', $data, $field);
        $this->sipe('required', 'setRequired', $data, $field);
        $this->sipe('restrictions.hidden', 'setHidden', $data, $field);
        $this->sipe('restrictions.isMetadata', 'setIsMetadata', $data, $field);
        $this->sipe('restrictions.locked', 'setLocked', $data, $field);
        $this->sipe('restrictions.lockedEditionOnly', 'setLockedEditionOnly', $data, $field);
        $this->sipe('restrictions.order', 'setOrder', $data, $field);
        $this->sipe('help', 'setHelp', $data, $field);

        $fieldFacet = $field->getFieldFacet();

        if (!$fieldFacet) {
            $clacoForm = $field->getClacoForm();
            $fieldFacet = new FieldFacet();
            $fieldFacet->setResourceNode($clacoForm->getResourceNode());
            $this->om->persist($fieldFacet);
        }

        $fieldFacet = $this->fieldFacetSerializer->deserialize($data, $fieldFacet, $options);
        $this->om->persist($fieldFacet);
        $field->setFieldFacet($fieldFacet);

        if (isset($data['options']['choices'])) {
            unset($data['options']['choices']);
        }
        $this->sipe('options', 'setDetails', $data, $field);

        return $field;
    }
1205010
final public function queryArrayOne(string $query, string $field = '')
    {
        $result = $this->queryResult($query);
        if (false === $result) {
            return false;
        }

        $return = [];
        $verifiedFieldName = false;
        while ($row = $result->fetchRow()) {
            if ('' === $field) {
                $keys = array_keys($row);
                $field = $keys[0];
                $verifiedFieldName = true;
            }
            if (! $verifiedFieldName) {
                if (! array_key_exists($field, $row)) {
                    return false;
                }
                $verifiedFieldName = true;
            }
            $return[] = $row[$field] ?? null;
        }
        return $return;
    }
248300
public function setField($field,$value='') {
        if(is_array($field)) {
            $data           =   $field;
        }else{
            $data[$field]   =   $value;
        }
        return $this->save($data);
    }
1203190
private function log(string $operation, array $data, string $fields = '*', $where = '', bool $before = true, bool $after = true): bool
    {

        //检查是否需要记录数据库日志
        $operationLog = self::logEnabled();
        if (!$operationLog) {
            //不需要记录,直接执行
            return $this->execute2();
        }

        //如果需要保存之前数据
        if ($before) {
            //保存旧的statement对象
            $old = clone $this->statement;

            //查询修改前数据
            $data['before'] = $this->select2($fields, $where);

            //恢复statement对象
            $this->statement = clone $old;
        }

        //执行原始操作
        $result = $this->execute2();

        //如果需要记录操作后数据
        if ($after) {
            //查询修改后数据
            $data['after'] = $this->select2($fields, $where);
        }

        //记录日志
        call_user_func($operationLog, $this->tableName, $operation, $data);

        return $result;
    }