Returns all of the rules set up for the $field.

@param string $field

@return string[]

```php
foreach ($validator->rules($field) as $validate => $param) {
$attributes["data-rule-{$validate}"] = htmlspecialchars($param);
}
```
6350
public function rules($field)
    {
        return (isset($this->data[$field]) && $validate = $this->data[$field]['validate']) ? $validate : array();
    }
60386
private function errorMessages(string $field, array $errors): array {
        $messages = [];

        foreach ($errors as $error) {
            $messages[] = $this->formatErrorMessage($error + ['field' => $field]);
        }
        return $messages;
    }
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;
    }
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;
    }
52305
function load_field_defaults( $field )
	{
		// validate $field
		if( !is_array($field) )
		{
			$field = array();
		}
		
		
		// defaults
		$defaults = array(
			'key' => '',
			'label' => '',
			'name' => '',
			'_name' => '',
			'type' => 'text',
			'order_no' => 1,
			'instructions' => '',
			'required' => 0,
			'id' => '',
			'class' => '',
			'conditional_logic' => array(
				'status' => 0,
				'allorany' => 'all',
				'rules' => 0
			),
		);
		$field = array_merge($defaults, $field);
		
		
		// Parse Values
		$field = apply_filters( 'acf/parse_types', $field );
		
		
		// field specific defaults
		$field = apply_filters('acf/load_field_defaults/type=' . $field['type'] , $field);
				
		
		// class
		if( !$field['class'] )
		{
			$field['class'] = $field['type'];
		}
		
		
		// id
		if( !$field['id'] )
		{
			$id = $field['name'];
			$id = str_replace('][', '_', $id);
			$id = str_replace('fields[', '', $id);
			$id = str_replace('[', '-', $id); // location rules (select) does'nt have "fields[" in it
			$id = str_replace(']', '', $id);
			
			$field['id'] = 'acf-field-' . $id;
		}
		
		
		// _name
		if( !$field['_name'] )
		{
			$field['_name'] = $field['name'];
		}
		
		
		// clean up conditional logic keys
		if( !empty($field['conditional_logic']['rules']) )
		{
			$field['conditional_logic']['rules'] = array_values($field['conditional_logic']['rules']);
		}
		
		
		// return
		return $field;
	}
1251762
protected function validateField(string $field, string $rule): bool
	{
		$parsedRule = $this->parseRule($rule);

		$rule = $this->ruleFactory($parsedRule->name, $parsedRule->parameters);

		// Just return true if the input field is empty and the rule doesn't validate empty input

		if($this->isInputFieldEmpty($inputValue = Arr::get($this->input, $field)) && $rule->validateWhenEmpty() === false)
		{
			return true;
		}

		// Validate input

		if($rule->validate($inputValue, $this->input) === false)
		{
			$this->errors[$field] = $this->getErrorMessage($rule, $field, $parsedRule);

			return $this->isValid = false;
		}

		return true;
	}
325394
public function getFieldErrors($field) {
		$existing = array_key_get($this->errors['fields'], $field['options']['name']);
		if (!empty($existing)) {
			$result = [
				'type' => null,
				'message' => '',
				'counters' => []
			];
			$sorted = [
				'danger' => [],
				'warning' => [],
				'success' => [],
				'info' => []
			];
			$types = array_keys($existing);
			if (in_array('danger', $types)) {
				$result['type'] = 'danger';
			} else {
				$temp = current($types);
				$result['type'] = $temp;
			}
			// generating text messages
			foreach ($existing as $k => $v) {
				foreach ($v as $k2 => $v2) {
					$result['counters'][$k] = ($result[$k] ?? 0) + 1;
					$sorted[$k][$k2] = $v2;
				}
			}
			foreach ($sorted as $k => $v) {
				if (empty($v)) continue;
				foreach ($v as $k2 => $v2) {
					$result['message'].= \HTML::text(['tag' => 'div', 'class' => 'numbers_field_error_messages', 'data-field_value_hash' => $k2, 'type' => $k, 'value' => $v2]);
				}
			}
			return $result;
		}
		return null;
	}
254979
protected function getFieldItems(Field $field)
    {
        if ($field->hasForeignRelation() && $field->isOnFormView) {
            return sprintf('$%s', $field->getForeignRelation()->getCollectionName());
        }
        $labels = $field->getOptionsByLang();
        return sprintf('[%s]', implode(',' . PHP_EOL, $this->getKeyValueStringsFromLabels($labels)));
    }
446719
public function messages($field = '')
    {
        if ($field) {
            return isset($this->errorMessages[$field]) ? $this->errorMessages[$field] : [];
        }

        $messages = [];

        array_walk_recursive($this->errorMessages, function ($message) use (&$messages) {
            $messages[] = $message;
        });

        return $messages;
    }
664967
public function getBlockVariables($field, $entity)
    {
        $defaults = parent::getBlockVariables($field, $entity);

        $data = $defaults['value'];

        if ($data instanceof \Traversable) {
            $dataArray = [];
            foreach ($data as $element) {
                $dataArray[] = $element->__toString();
            }

            $string = implode(', ', $dataArray);
        } else if (is_array($data)) {
            $string = implode(', ', $data);
        } else {
            $string = 'Unsupported.';
        }

        return [
            'value' => $string,
            'truncate' => $field->getOption('truncate', 80),
        ] + $defaults;
    }
429153
public function getField($field)
    {
        return isset($this->data[$field])
            ? $this->data[$field]
            : $this->searchField($field);
    }
89155
public function parse($fields)
    {
        if ( ! $fields) return [];

        // name:string, age:integer
        // name:string(10,2), age:integer
        $fields = preg_split('/\s?,\s/', $fields);

        $parsed = [];

        foreach($fields as $index => $field)
        {
            // Example:
            // name:string:nullable => ['name', 'string', 'nullable']
            // name:string(15):nullable
            $chunks = preg_split('/\s?:\s?/', $field, null);

            // The first item will be our property
            $property = array_shift($chunks);

            // The next will be the schema type
            $type = array_shift($chunks);

            $args = null;

            // See if args were provided, like:
            // name:string(10)
            if (preg_match('/(.+?)\(([^)]+)\)/', $type, $matches))
            {
                $type = $matches[1];
                $args = $matches[2];
            }

            // Finally, anything that remains will
            // be our decorators
            $decorators = $chunks;

            $parsed[$index] = ['field' => $property, 'type' => $type];

            if (isset($args)) $parsed[$index]['args'] = $args;
            if ($decorators) $parsed[$index]['decorators'] = $decorators;
        }

        return $parsed;
    }
325838
private function getScalarField($field)
	{
		$dataField = array_merge($this->defaultField, [
			'property' => $field->getName(),
			'title' => $field->getTitle(),
			'type' => get_class($field),
			'validators' => $field->getValidators(),
			'modifiers' => [
				'save' => $field->getSaveDataModifiers(),
				'fetch' => $field->getFetchDataModifiers(),
			],
		]);

		if($field instanceof Main\Entity\ScalarField){
			$dataField['primary'] = $field->isPrimary();
			$dataField['unique'] = $field->isUnique();
			$dataField['autocomplete'] = $field->isAutocomplete();
			$dataField['require'] = $field->isRequired();
			$dataField['serialized'] = $field->isSerialized();
			if(method_exists($field, 'getValues')){
				$dataField['values'] = $field->getValues();
			}
		} elseif ($field instanceof Main\Entity\ReferenceField){
			$ref = $field->getReference();
			$ref = array_shift($ref);

			preg_match('/^ref\.([a-zA-Z]+)$/i', $ref, $matchRef);

			$refEntity = $field->getRefEntity();
			$refNameShow = $matchRef[1];
			if($refEntity->hasField('NAME')){
				$refNameShow = $refEntity->getField('NAME')->getName();
			} elseif ($refEntity->hasField('TITLE')){
				$refNameShow = $refEntity->getField('TITLE')->getName();
			}
			$dataField['property'] = $field->getName().'_REF_'.$refNameShow;
			$dataField['virtual'] = true;
			$dataField['reference'] = [
				'FROM' => $field->getName(),
				'TO' => $refNameShow,
			];
		}

		return $dataField;
	}
49090
protected function getValidationRules(array $fields)
    {
        $rules = [];

        foreach($fields as $field => $data){

            if($data['validate']) $rules[$field] = $data['validate'];

        }

        return $rules;
    }
250461
protected function getStrategySpecificRules(ModelFormFieldDataInterface $field = null)
    {
        $key = $this->formFieldData->key();

        $rules = [
            'longitude' => [ 'numeric' ],
            'latitude'  => [ 'numeric' ],
            'text'      => [ 'string', 'nullable' ],
        ];

        // Always require long/lat if the field itself is required
        // If not, only require them if the attributes are non-nullable (todo)
        $required = $this->formFieldData->required();

        if ($required) {
            $rules[ 'longitude' ][] = 'required';
            $rules[ 'latitude' ][]  = 'required';
        } else {
            $rules[ 'longitude' ][] = 'nullable';
            $rules[ 'latitude' ][]  = 'nullable';
        }

        // todo: determine whether text column, if made available, is required

        return array_map(
            function (array $rules, $key) {
                return new ValidationRuleData($rules, $key);
            },
            array_values($rules),
            array_keys($rules)
        );
    }
1141105
protected static function getValidationConfigByField($field)
    {
        $data = config('laravel-sms.validation', []);
        if (isset($data[$field])) {
            return $data[$field];
        }
        throw new LaravelSmsException("Not find the configuration information of field `$field`, please define it.");
    }
1129022
public function rules()
    {
        return [
            'name' => [
                'required',
                'string',
                'between:3,255',
                'regex:/^[\w\s\.\,\-\_]+$/u',
            ],
            'email' => [
                'required',
                'email',
                'between:6,255',
                'unique:users,email' . (isset($this->user->id) ? ','.$this->user->id.',id' : ''),
            ],
            'password' => [
                'string',
                'between:6,255',
                'confirmed',
                isset($this->user->id) ? 'nullable' : 'required',
            ],
            'role' => [
                'sometimes',
                'required',
                'string',
                'max:255',
                'in:' . implode(',', cache('roles')),
            ],
            'where_from' => [
                'nullable',
                'string',
                'max:255',
                'alpha_num',
            ],
            'info' => [
                'nullable',
                'string',
                'max:500',
                'regex:/^[\w\s\.\,\-\_\?\!\r\n]+$/u',
            ],
            'avatar' => [
                'nullable',
                'image',
                'mimes:png,jpg,jpeg,gif,bmp',
                'max:800',
                'dimensions:max_width='.setting('users.avatar_max_width', 140).',max_height='.setting('users.avatar_max_height', 140),
            ],
        ];
    }