验证

@param string $field
@param array $data
@return bool|string
777830
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 (in_array($value, $this->range, $this->isStrict)) {
            return true;
        }

        return $this->message('{fieldName}不在允许的范围内！', [
            '{fieldName}' => $this->getName($field),
        ]);
    }
1054878
public function email($field)
    {
        return (filter_var(trim($this->get($field)), FILTER_VALIDATE_EMAIL) !== false) ?: $this->error($field,
            __FUNCTION__);
    }
964212
public function setField($field, $value = '')
    {
        $condition = !empty($this->options['where']) ? $this->options['where'] : [];

        if (empty($condition)) {
            // 没有条件不做任何更新
            throw new Exception('no data to update');
        }

        if (is_array($field)) {
            $data = $field;
        } else {
            $data[$field] = $value;
        }

        return $this->update($data);
    }
439895
public static function check( array $fields, array $data ) {
		$dependency = new static( $data );

		foreach ( $fields as $field ) {
			if ( ! $field->get_option( 'deps' ) ) {
				continue;
			}

			$satisfied = $dependency->apply(
				$deps = $field->get_option( 'deps' )
			);

			$field->set_option( 'row_attributes',
				$field->get_option( 'row_attributes' ) + [
					'data-deps'      => esc_attr( json_encode( $deps, JSON_HEX_APOS ) ),
					'data-satisfied' => $satisfied ? 'true' : 'false',
				]
			);

			$field->set_option( 'active', $satisfied );
		}
	}
248300
public function setField($field,$value='') {
        if(is_array($field)) {
            $data           =   $field;
        }else{
            $data[$field]   =   $value;
        }
        return $this->save($data);
    }
1006439
public function max($field) {
        $this->statementContext->setFields("MAX({$field}) AS __MAX__");
        $row = $this->findOne();

        //SQL执行发生错误
        if ($row === false) {
            return false;
        }

        return $row['__MAX__'];
    }
690648
public function max($field) {
        $this->build()->bindExpression('field', "max({$field}) AS m");
        $data = $this->first();

        return $data ? $data['m'] : '';
    }
1022667
public function getField($field)
    {
        return isset($this->data[$field]) ? $this->data[$field] : null;
    }
83653
public function validator($field, array $data)
    {
        $value = isset($data[$field]) ? $data[$field] : null;
        $targetValue = isset($data[$this->target]) ? $data[$this->target] : null;
        if ($value === $targetValue) {
            return true;
        }

        return $this->message('{fieldName}与{targetName}不相等！', [
            '{fieldName}' => $this->getName($field),
            '{targetName}' => $this->getName($this->target),
        ]);
    }
111292
public function build_field($field)
	{
		! $field instanceof Fieldset_Field && $field = $this->field($field);

		return $field->build();
	}
523585
public function field($field)
    {
        return $this->fieldFactory->createFromField(
            $this->getFieldData($field),
            $this->getFieldValue($field)
        );
    }
1287623
protected function get($field)
    {
        if (isset($this->raw[$field])) {
            return $this->raw[$field];
        }
        if (preg_match('/^is_/', $field)) {
            return false;
        }

        return null;
    }
1345357
public function setField($field, $value = '')
    {
        if (is_array($field)) {
            $data = $field;
        } else {
            $data[$field] = $value;
        }
        return $this->update($data);
    }
20512
public function update($field_id, array $data)
    {
        $result = null;
        $this->hook->attach('field.update.before', $field_id, $data, $result, $this);

        if (isset($result)) {
            return (bool) $result;
        }

        unset($data['type']);

        $updated = $this->db->update('field', $data, array('field_id' => $field_id));
        $data['field_id'] = $field_id;
        $updated += (int) $this->setTranslations($data, $this->translation_entity, 'field');

        $result = $updated > 0;
        $this->hook->attach('field.update.after', $field_id, $data, $result, $this);
        return (bool) $result;
    }
263841
public function field_format_value($fields, $data) 
    {
        if (!$fields || !$data || !is_array($data)) {
            return $data;
        }
        foreach ($fields as $field) {
            $obj = $this->get($field['fieldtype']);
            if (!$obj) {
                continue;
            }
            if ($field['fieldtype'] === 'Group') {
                continue;
            }
            $data = $obj->output_data($data, $field);
        }
        return $data;
    }
1349794
protected function formatField(Field $field)
    {
        $jsonKey = $field->column();

        $elementName = $elementClass = $errorKey = [];

        if (is_array($jsonKey)) {
            foreach ($jsonKey as $index => $name) {
                $elementName[$index] = "{$this->column}[$name]";
                $errorKey[$index] = "{$this->column}.$name";
                $elementClass[$index] = "{$this->column}_$name";
            }
        } else {
            $elementName = "{$this->column}[$jsonKey]";
            $errorKey = "{$this->column}.$jsonKey";
            $elementClass = "{$this->column}_$jsonKey";
        }

        $field->setElementName($elementName)
            ->setErrorKey($errorKey)
            ->setElementClass($elementClass);

        return $field;
    }
557017
private function validateField($field, $data, $rules) {
		foreach ($rules as $rule) {
			list($m, $ops, $msg) = $rule;
			$valid_m = 'v_' . $m;
			if (method_exists($this, $valid_m)) {
				if ($msg) {
					$msg = preg_replace('#\{\d+?\}#', '%s', $msg);
				}
				$valid = $this->$valid_m ($field, $ops, $data, $msg);
			} else {
				return _t('notsupportmethod@validator', $field, $m);
			}
			if ($valid !== true) {
				return $valid;
			}
		}

		return true;
	}