ArcoFormRule class

校验规则,对应官方 FormItem.rules 数组项的常用子集。

rules: const <ArcoFormRule>[
  ArcoFormRule.required(),
  ArcoFormRule.minLength(2),
]

Constructors

ArcoFormRule.custom(String? validator(Object? value), {String? message})
自定义校验:返回错误文案表示不通过,返回 null 表示通过。
const
ArcoFormRule.length(int value, {String? message})
精确长度。
const
ArcoFormRule.maxLength(int value, {String? message})
最大长度。
const
ArcoFormRule.minLength(int value, {String? message})
最小长度(按 String.length 计)。
const
ArcoFormRule.pattern(RegExp pattern, {String? message})
正则匹配(空值跳过,交由必填规则处理)。
const
ArcoFormRule.required({String? message})
非空校验(字符串去首尾空格后非空)。
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
isRequired → bool
是否为必填规则(决定标签前的红色星标,同官方 isRequiredRule)。
final
length → int?
final
maxLength → int?
final
message → String?
final
minLength → int?
final
pattern → RegExp?
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
validator → String? Function(Object? value)?
自定义校验函数。
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
validate(Object? value, String label) → String?
校验 value,返回错误文案;null 表示通过。label 用于默认文案。

Operators

operator ==(Object other) → bool
The equality operator.
inherited