JunnyFormFieldValidatorConfig<T> class
Field validation related configuration for defining validators 字段验证相关的配置,用于定义验证器
Example usage:
JunnyFormFieldValidatorConfig(
asyncDebounce: Duration(milliseconds: 500),
asyncValidator: (value) async {
await Future.delayed(Duration(seconds: 2)); // Simulate async validation
if (value != "valid") {
return "Invalid value";
}
return null;
},
autovalidateMode: AutovalidateMode.always,
forceErrorTextGetter: () => "This field is required",
required: true,
validator: (value) {
if (value == null || value.isEmpty) {
return "Field cannot be empty";
}
return null;
},
)
- Annotations
Constructors
-
JunnyFormFieldValidatorConfig({Duration? asyncDebounce, AsyncFieldValidator<
T> ? asyncValidator, AutovalidateMode? autovalidateMode, ValueGetter<String?> ? forceErrorTextGetter, ValueGetter<bool> ? requiredGetter, FormFieldValidator<T> ? validator})
Properties
- asyncDebounce → Duration?
-
Debounce duration for async validation (to avoid multiple rapid requests)
异步验证的防抖时间(避免快速多次请求)
示例:
final
-
asyncValidator
→ AsyncFieldValidator<
T> ? -
Asynchronous validator function for the form field
表单字段的异步验证函数
示例:
final
- autovalidateMode → AutovalidateMode?
-
Mode for automatic validation on user input changes
自动验证模式,用于用户输入变化时自动触发验证
示例:
final
-
forceErrorTextGetter
→ ValueGetter<
String?> ? -
An optional property that forces the FormFieldState into an error state
by directly setting the FormFieldState.errorText property without
running the validator function.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
requiredGetter
→ ValueGetter<
bool> ? -
Whether the form field is required to be filled
字段是否为必填项
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
validator
→ FormFieldValidator<
T> ? -
Synchronous validator function for the form field
表单字段的同步验证函数
示例:
final
Methods
-
copyWith(
{Duration? asyncDebounce, AsyncFieldValidator< T> ? asyncValidator, AutovalidateMode? autovalidateMode, ValueGetter<String?> ? forceErrorTextGetter, ValueGetter<bool> ? requiredGetter, FormFieldValidator<T> ? validator}) → JunnyFormFieldValidatorConfig<T> - Creates a copy of this object with the given fields replaced with the new values. 复制当前对象,并用新值替换指定字段
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited