WFormValidator class

表单验证器类,用于管理和执行表单验证

持有表单数据 formData、验证项列表 validationItems 与 config, 由 validate 按顺序执行校验,行为由 WFormValidatorConfig 控制: 短路 / 全量校验、是否显示边框错误、首个失败项的自动聚焦、 错误提示回调的触发范围;校验结果可通过只读的 errors 获取。

建议以本类作为统一校验入口:错误文案统一由 WFormBorder 展示, 不会写入字段的 errorText(避免与 InputDecoration 双通道)。 直接调用 formKey.currentState.validate() 时仍走原生字段错误展示, 仅 text / dropdown 会渲染文案,自定义构建的字段不渲染。

Constructors

WFormValidator({required WFormData formData, required List<WFormValidatorItem> validationItems, WFormValidatorConfig? config})
创建表单验证器

Properties

config ↔ WFormValidatorConfig?
验证器配置
getter/setter pair
errors → Map<String, String>
最近一次校验的失败项集合(字段名 -> 错误文本),只读快照
no setter
formData ↔ WFormData
表单数据对象
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
validationItems ↔ List<WFormValidatorItem>
验证项列表
getter/setter pair

Methods

add(WFormValidatorItem item) → void
添加验证项
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
validate() → bool
执行验证,返回是否全部通过

Operators

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