IpValidator class
A validator that checks if the value is a valid ip.
The IpValidator can be used with FieldControllers holding
values of type String
. It ensures that the
value is a valid ip.
If the value is null
it is treated as valid by default.
Properties
- ipType: The type of ip to validate. Can be IpType.ipV4, IpType.ipV6 or IpType.ipV6Short
- message: An optional custom error message to display when invalid.
Example
FieldController<String> field = FieldController(
key: 'string',
validators:[IpValidator(IpType.ipV4)],
);
// If field.value = '1234.456.78', validation fails.
// If field.value = '123.456.7.8, validation passes.
See also
- FormyValidator, the base class for custom validators.
- ValidationResult, which describes the outcome of validation.
- FieldController, which holds the field value to be validated.
- Inheritance
-
- Object
- FormyValidator<
String> - IpValidator
Constructors
- IpValidator.new(IpType ipType, {String? message})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- ipType → IpType
-
The type of ip to validate. Can be IpType.ipV4, IpType.ipV6 or IpType.ipV6Short
final
- message → String?
-
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
FieldController< String> controller) → ValidationResult -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onValidate(
FieldController< String> controller) → ValidationResult -
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited