Skip to content

Commit 3aec2ae

Browse files
committed
Docs
1 parent e2a1cdf commit 3aec2ae

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
lines changed

lib/src/network/ip_validator.dart

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
import '../../localization/l10n.dart';
22
import '../base_validator.dart';
33

4+
/// {@template ip_validator_template}
5+
/// [IpValidator] extends [BaseValidator] to validate if a string represents a valid IPv4 or IPv6 address.
6+
///
7+
/// This validator checks if the IP address matches the specified regex pattern for either IPv4 or IPv6.
8+
///
9+
/// ## Parameters:
10+
///
11+
/// - [version] The IP version to validate (either 4 or 6). Defaults to 4.
12+
/// - [regex] The regular expression used to validate the IP address format. Defaults to standard IPv4 or IPv6 regex.
13+
/// - [errorText] The error message returned if the validation fails.
14+
/// - [checkNullOrEmpty] Whether to check if the value is null or empty.
15+
///
16+
/// {@endtemplate}
417
class IpValidator extends BaseValidator<String> {
18+
/// Constructor for the IP address validator.
519
IpValidator({
620
this.version = 4,
721

@@ -16,8 +30,10 @@ class IpValidator extends BaseValidator<String> {
1630
super.checkNullOrEmpty,
1731
});
1832

33+
/// The IP version to validate (either 4 or 6).
1934
final int version;
2035

36+
/// The regular expression used to validate the IP address format.
2137
final RegExp? regex;
2238

2339
/// {@template ipv4_template}
@@ -54,7 +70,7 @@ class IpValidator extends BaseValidator<String> {
5470
return !isIP(valueCandidate, version) ? errorText : null;
5571
}
5672

57-
/// check if the string [str] is IP [version] 4 or 6
73+
/// Check if the string [str] is IP [version] 4 or 6.
5874
///
5975
/// * [version] is a String or an `int`.
6076
bool isIP(String? str, int version) {

lib/src/network/latitude_validator.dart

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
import '../../localization/l10n.dart';
22
import '../base_validator.dart';
33

4+
/// {@template latitude_validator_template}
5+
/// [LatitudeValidator] extends [BaseValidator] to validate if a string represents a valid latitude value.
6+
///
7+
/// This validator checks if the latitude value is a number within the range of -90 to 90 degrees.
8+
///
9+
/// ## Parameters:
10+
///
11+
/// - [errorText] The error message returned if the validation fails.
12+
/// - [checkNullOrEmpty] Whether to check if the value is null or empty.
13+
///
14+
/// {@endtemplate}
415
class LatitudeValidator extends BaseValidator<String> {
16+
/// Constructor for the latitude validator.
517
const LatitudeValidator({
6-
/// {@macro longitude_validator_error_text}
18+
/// {@macro base_validator_error_text}
719
super.errorText,
820

921
/// {@macro base_validator_null_check}
@@ -12,14 +24,20 @@ class LatitudeValidator extends BaseValidator<String> {
1224

1325
@override
1426
String get translatedErrorText =>
15-
FormBuilderLocalizations.current.longitudeErrorText;
27+
FormBuilderLocalizations.current.latitudeErrorText;
1628

1729
@override
1830
String? validateValue(String valueCandidate) {
1931
return isLatitude(valueCandidate) ? null : errorText;
2032
}
2133

22-
/// check if the string is a valid latitude
34+
/// Check if the string is a valid latitude.
35+
///
36+
/// ## Parameters:
37+
/// - [value] The string to be evaluated.
38+
///
39+
/// ## Returns:
40+
/// A boolean indicating whether the value is a valid latitude.
2341
bool isLatitude(String value) {
2442
final String latitudeValue = value.replaceAll(',', '.');
2543

lib/src/network/longitude_validator.dart

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
import '../../localization/l10n.dart';
22
import '../base_validator.dart';
33

4+
/// {@template longitude_validator_template}
5+
/// [LongitudeValidator] extends [BaseValidator] to validate if a string represents a valid longitude value.
6+
///
7+
/// This validator checks if the longitude value is a number within the range of -180 to 180 degrees.
8+
///
9+
/// ## Parameters:
10+
///
11+
/// - [errorText] The error message returned if the validation fails.
12+
/// - [checkNullOrEmpty] Whether to check if the value is null or empty.
13+
///
14+
/// {@endtemplate}
415
class LongitudeValidator extends BaseValidator<String> {
16+
/// Constructor for the longitude validator.
517
const LongitudeValidator({
6-
/// {@macro longitude_validator_error_text}
18+
/// {@macro base_validator_error_text}
719
super.errorText,
820

921
/// {@macro base_validator_null_check}
@@ -19,7 +31,13 @@ class LongitudeValidator extends BaseValidator<String> {
1931
return isLongitude(valueCandidate) ? null : errorText;
2032
}
2133

22-
/// check if the string is a valid longitude
34+
/// Check if the string is a valid longitude.
35+
///
36+
/// ## Parameters:
37+
/// - [value] The string to be evaluated.
38+
///
39+
/// ## Returns:
40+
/// A boolean indicating whether the value is a valid longitude.
2341
bool isLongitude(String value) {
2442
final String longitudeValue = value.replaceAll(',', '.');
2543

0 commit comments

Comments
 (0)