Skip to content

Commit e2a1cdf

Browse files
committed
Docs
1 parent a3fa6aa commit e2a1cdf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+793
-28
lines changed

lib/src/bool/has_special_chars_validator.dart

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

4+
/// {@template has_special_chars_template}
5+
/// [HasSpecialCharsValidator] extends [BaseValidator] to validate if a string
6+
/// contains a specified minimum number of special characters.
7+
///
8+
/// ## Parameters:
9+
///
10+
/// - [atLeast] The minimum number of special characters required.
11+
/// - [regex] The regular expression used to identify special characters.
12+
/// - [errorText] The error message returned if the validation fails.
13+
///
14+
/// {@macro special_chars_template}
15+
/// {@endtemplate}
416
class HasSpecialCharsValidator extends BaseValidator<String> {
17+
/// Constructor for the special characters validator.
518
HasSpecialCharsValidator({
619
this.atLeast = 1,
720

@@ -15,8 +28,10 @@ class HasSpecialCharsValidator extends BaseValidator<String> {
1528
super.checkNullOrEmpty,
1629
}) : regex = regex ?? _specialChar;
1730

31+
/// The minimum number of special characters required.
1832
final int atLeast;
1933

34+
/// The regular expression used to identify special characters.
2035
final RegExp regex;
2136

2237
@override
@@ -38,6 +53,13 @@ class HasSpecialCharsValidator extends BaseValidator<String> {
3853
return specialCharLength(valueCandidate) >= atLeast ? null : errorText;
3954
}
4055

56+
/// Calculates the number of special characters in the given value.
57+
///
58+
/// ## Parameters:
59+
/// - [value] The string to be evaluated.
60+
///
61+
/// ## Returns:
62+
/// The count of special characters in the string.
4163
int specialCharLength(String value) {
4264
return regex.allMatches(value).length;
4365
}

lib/src/bool/has_uppercase_chars_validator.dart

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

4+
/// {@template has_uppercase_chars_template}
5+
/// [HasUppercaseCharsValidator] extends [BaseValidator] to validate if a string
6+
/// contains a specified minimum number of uppercase characters.
7+
///
8+
/// ## Parameters:
9+
///
10+
/// - [atLeast] The minimum number of uppercase characters required.
11+
/// - [regex] The regular expression used to identify uppercase characters.
12+
/// - [errorText] The error message returned if the validation fails.
13+
///
14+
/// {@macro upper_case_template}
15+
/// {@endtemplate}
416
class HasUppercaseCharsValidator extends BaseValidator<String> {
17+
/// Constructor for the uppercase characters validator.
518
HasUppercaseCharsValidator({
619
this.atLeast = 1,
720

@@ -15,21 +28,23 @@ class HasUppercaseCharsValidator extends BaseValidator<String> {
1528
super.checkNullOrEmpty,
1629
}) : regex = regex ?? _upperCase;
1730

31+
/// The minimum number of uppercase characters required.
1832
final int atLeast;
1933

34+
/// The regular expression used to identify uppercase characters.
2035
final RegExp regex;
2136

2237
@override
2338
String get translatedErrorText =>
2439
FormBuilderLocalizations.current.containsUppercaseCharErrorText(atLeast);
2540

2641
/// {@template upper_case_template}
27-
/// This regex matches any character that is not an uppercase letter (A-Z).
42+
/// This regex matches any character that is an uppercase letter (A-Z).
2843
///
29-
/// - It includes special characters, digits, and lowercase letters.
30-
/// - It can be used to find non-uppercase characters.
44+
/// - It includes all uppercase letters.
45+
/// - It can be used to find uppercase characters.
3146
///
32-
/// Examples: a, 1, @
47+
/// Examples: A, B, C
3348
/// {@endtemplate}
3449
static final RegExp _upperCase = RegExp('[A-Z]');
3550

@@ -38,6 +53,13 @@ class HasUppercaseCharsValidator extends BaseValidator<String> {
3853
return uppercaseCharLength(valueCandidate) >= atLeast ? null : errorText;
3954
}
4055

56+
/// Calculates the number of uppercase characters in the given value.
57+
///
58+
/// ## Parameters:
59+
/// - [value] The string to be evaluated.
60+
///
61+
/// ## Returns:
62+
/// The count of uppercase characters in the string.
4163
int uppercaseCharLength(String value) {
4264
return regex.allMatches(value).length;
4365
}

lib/src/bool/is_false_validator.dart

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

4+
/// {@template is_false_validator_template}
5+
/// [IsFalseValidator] extends [BaseValidator] to validate if a boolean value is false.
6+
///
7+
/// ## Parameters:
8+
///
9+
/// - [errorText] The error message returned if the validation fails.
10+
/// - [checkNullOrEmpty] Whether to check if the value is null or empty.
11+
///
12+
/// {@endtemplate}
413
class IsFalseValidator extends BaseValidator<bool> {
14+
/// Constructor for the false value validator.
515
const IsFalseValidator({
616
/// {@macro base_validator_error_text}
717
super.errorText,

lib/src/bool/is_true_validator.dart

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

4+
/// {@template is_true_validator_template}
5+
/// [IsTrueValidator] extends [BaseValidator] to validate if a boolean value is true.
6+
///
7+
/// ## Parameters:
8+
///
9+
/// - [errorText] The error message returned if the validation fails.
10+
/// - [checkNullOrEmpty] Whether to check if the value is null or empty.
11+
///
12+
/// {@endtemplate}
413
class IsTrueValidator extends BaseValidator<bool> {
14+
/// Constructor for the true value validator.
515
const IsTrueValidator({
616
/// {@macro base_validator_error_text}
717
super.errorText,

lib/src/collection/contains_element_validator.dart

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

4+
/// {@template contains_element_validator_template}
5+
/// [ContainsElementValidator] extends [BaseValidator] to validate if a value is
6+
/// contained within a specified list of values.
7+
///
8+
/// ## Parameters:
9+
///
10+
/// - [values] The list of values to check against.
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 ContainsElementValidator<T> extends BaseValidator<T> {
16+
/// Constructor for the contains element validator.
517
const ContainsElementValidator(
618
this.values, {
719
/// {@macro base_validator_error_text}
@@ -11,6 +23,7 @@ class ContainsElementValidator<T> extends BaseValidator<T> {
1123
super.checkNullOrEmpty,
1224
});
1325

26+
/// The list of values to check against.
1427
final List<T> values;
1528

1629
@override

lib/src/collection/equal_length_validator.dart

Lines changed: 16 additions & 0 deletions
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 equal_length_validator_template}
5+
/// [EqualLengthValidator] extends [BaseValidator] to validate if a value has a specified length.
6+
///
7+
/// This validator works with various types, including String, Iterable, and Map.
8+
///
9+
/// ## Parameters:
10+
///
11+
/// - [length] The exact length the value should have.
12+
/// - [allowEmpty] Whether to allow empty values.
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 EqualLengthValidator<T> extends BaseValidator<T> {
18+
/// Constructor for the equal length validator.
519
const EqualLengthValidator(
620
this.length, {
721
this.allowEmpty = false,
@@ -13,8 +27,10 @@ class EqualLengthValidator<T> extends BaseValidator<T> {
1327
super.checkNullOrEmpty,
1428
});
1529

30+
/// The exact length the value should have.
1631
final int length;
1732

33+
/// Whether to allow empty values.
1834
final bool allowEmpty;
1935

2036
@override

lib/src/collection/max_length_validator.dart

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

4+
/// {@template max_length_validator_template}
5+
/// [MaxLengthValidator] extends [BaseValidator] to validate if a value does not exceed a specified maximum length.
6+
///
7+
/// This validator works with various types, including String, Iterable, and Map.
8+
///
9+
/// ## Parameters:
10+
///
11+
/// - [maxLength] The maximum length the value is allowed to have.
12+
/// - [errorText] The error message returned if the validation fails.
13+
/// - [checkNullOrEmpty] Whether to check if the value is null or empty.
14+
///
15+
/// {@endtemplate}
416
class MaxLengthValidator<T> extends BaseValidator<T> {
17+
/// Constructor for the maximum length validator.
518
const MaxLengthValidator(
619
this.maxLength, {
720
/// {@macro base_validator_error_text}
@@ -11,6 +24,7 @@ class MaxLengthValidator<T> extends BaseValidator<T> {
1124
super.checkNullOrEmpty,
1225
});
1326

27+
/// The maximum length the value is allowed to have.
1428
final int maxLength;
1529

1630
@override

lib/src/collection/min_length_validator.dart

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

4+
/// {@template min_length_validator_template}
5+
/// [MinLengthValidator] extends [BaseValidator] to validate if a value meets a specified minimum length.
6+
///
7+
/// This validator works with various types, including String, Iterable, and Map.
8+
///
9+
/// ## Parameters:
10+
///
11+
/// - [minLength] The minimum length the value is required to have.
12+
/// - [errorText] The error message returned if the validation fails.
13+
/// - [checkNullOrEmpty] Whether to check if the value is null or empty.
14+
///
15+
/// {@endtemplate}
416
class MinLengthValidator<T> extends BaseValidator<T> {
17+
/// Constructor for the minimum length validator.
518
const MinLengthValidator(
619
this.minLength, {
720
/// {@macro base_validator_error_text}
@@ -11,6 +24,7 @@ class MinLengthValidator<T> extends BaseValidator<T> {
1124
super.checkNullOrEmpty,
1225
});
1326

27+
/// The minimum length the value is required to have.
1428
final int minLength;
1529

1630
@override

lib/src/collection/range_validator.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
import '../../form_builder_validators.dart';
22

3+
/// {@template range_validator_template}
4+
/// [RangeValidator] extends [BaseValidator] to validate if a value falls within a specified range.
5+
///
6+
/// This validator works with various types, including numeric types and collections.
7+
///
8+
/// ## Parameters:
9+
///
10+
/// - [min] The minimum value of the range.
11+
/// - [max] The maximum value of the range.
12+
/// - [inclusive] Whether the range is inclusive of the min and max values.
13+
/// - [errorText] The error message returned if the validation fails.
14+
/// - [checkNullOrEmpty] Whether to check if the value is null or empty.
15+
///
16+
/// This validator uses [MinValidator], [MaxValidator], [MinLengthValidator], and [MaxLengthValidator] internally.
17+
///
18+
/// {@endtemplate}
319
class RangeValidator<T> extends BaseValidator<T> {
20+
/// Constructor for the range validator.
421
RangeValidator(
522
this.min,
623
this.max, {
@@ -34,18 +51,25 @@ class RangeValidator<T> extends BaseValidator<T> {
3451
checkNullOrEmpty: checkNullOrEmpty,
3552
);
3653

54+
/// The minimum value of the range.
3755
final num min;
3856

57+
/// The maximum value of the range.
3958
final num max;
4059

60+
/// Whether the range is inclusive of the min and max values.
4161
final bool inclusive;
4262

63+
/// Internal minimum value validator.
4364
final MinValidator<T> _minValidator;
4465

66+
/// Internal maximum value validator.
4567
final MaxValidator<T> _maxValidator;
4668

69+
/// Internal minimum length validator.
4770
final MinLengthValidator<T> _minLengthValidator;
4871

72+
/// Internal maximum length validator.
4973
final MaxLengthValidator<T> _maxLengthValidator;
5074

5175
@override

lib/src/collection/unique_validator.dart

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

4+
/// {@template unique_validator_template}
5+
/// [UniqueValidator] extends [BaseValidator] to validate if a value is unique within a specified list of values.
6+
///
7+
/// ## Parameters:
8+
///
9+
/// - [values] The list of values to check against for uniqueness.
10+
/// - [errorText] The error message returned if the validation fails.
11+
/// - [checkNullOrEmpty] Whether to check if the value is null or empty.
12+
///
13+
/// {@endtemplate}
414
class UniqueValidator<T> extends BaseValidator<T> {
15+
/// Constructor for the unique value validator.
516
const UniqueValidator(
617
this.values, {
718
/// {@macro base_validator_error_text}
@@ -11,6 +22,7 @@ class UniqueValidator<T> extends BaseValidator<T> {
1122
super.checkNullOrEmpty,
1223
});
1324

25+
/// The list of values to check against for uniqueness.
1426
final List<T> values;
1527

1628
@override

0 commit comments

Comments
 (0)