Skip to content

Commit

Permalink
fix class name
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobaraujo7 committed Aug 25, 2024
1 parent 36fa52b commit 48d1f73
Show file tree
Hide file tree
Showing 34 changed files with 94 additions and 94 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ class UserModel {
}
```

After that, create a `Validation` class and extends to `LucidValidation`:
After that, create a `LucidValidator` class and extends to `LucidValidator`:

```dart
import 'package:lucid_validation/lucid_validation.dart';
class UserValidation extends LucidValidation<UserModel> {
UserValidation() {
class UserValidator extends LucidValidator<UserModel> {
UserValidator() {
ruleFor((user) => user.email, key: 'email')
.notEmpty()
.validEmail();
Expand All @@ -69,7 +69,7 @@ Now, just validate!
void main() {
final user = UserModel(email: '[email protected]', password: 'Passw0rd!', age: 25);
final validator = UserValidation();
final validator = UserValidator();
final errors = validator.validate(user);
Expand All @@ -83,7 +83,7 @@ void main() {

Note, the validate method returns a list of errors with all validation exceptions.

### Available Validators
### Available Validations

Here’s a complete list of available validators you can use:

Expand Down
2 changes: 1 addition & 1 deletion example/lib/domain/validations/login_param_validation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:example/domain/dtos/login_param_dto.dart';
import 'package:example/domain/validations/extensions.dart';
import 'package:lucid_validation/lucid_validation.dart';

class LoginParamValidation extends LucidValidation<LoginParamDto> {
class LoginParamValidation extends LucidValidator<LoginParamDto> {
LoginParamValidation() {
ruleFor((loginParamDto) => loginParamDto.email, key: 'email') //
.notEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:example/domain/dtos/register_param_dto.dart';
import 'package:example/domain/validations/extensions.dart';
import 'package:lucid_validation/lucid_validation.dart';

class RegisterParamValidation extends LucidValidation<RegisterParamDto> {
class RegisterParamValidation extends LucidValidator<RegisterParamDto> {
RegisterParamValidation() {
ruleFor((registerParamDto) => registerParamDto.email, key: 'email') //
.notEmpty()
Expand Down
4 changes: 2 additions & 2 deletions lib/lucid_validation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@
///
library lucid_validation;

export 'src/lucid_validation.dart';
export 'src/lucid_validator.dart';
export 'src/types/types.dart';
export 'src/validators/validators.dart';
export 'src/validations/validations.dart';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of 'lucid_validation.dart';
part of 'lucid_validator.dart';

/// Defines the behavior of rule execution when a validation failure occurs.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../lucid_validation.dart';

part 'validator_builder.dart';
part 'lucid_validation_builder.dart';

class _PropSelector<E, TProp> {
final TProp Function(E entity) selector;
Expand All @@ -12,7 +12,7 @@ class _PropSelector<E, TProp> {
/// Abstract class for creating validation logic for a specific entity type [E].
///
/// [E] represents the type of the entity being validated.
abstract class LucidValidation<E> {
abstract class LucidValidator<E> {
final List<_PropSelector<E, dynamic>> _propSelectors = [];

/// Registers a validation rule for a specific property of the entity.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [T] properties to add an equality validation.
///
/// This extension adds an `equalTo` method that can be used to ensure that a value
/// is equal to a specific value.
extension EqualValidator<T, E> on LucidValidationBuilder<T, E> {
extension EqualValidation<T, E> on LucidValidationBuilder<T, E> {
/// Adds a validation rule that checks if the value is equal to [comparison].
///
/// [predicate] is a function that returns the value to compare against.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [num] properties to add a greater than validation.
///
/// This extension adds a `greaterThan` method that can be used to ensure that a number
/// is greater than a specified value.
extension GreaterThanValidator on LucidValidationBuilder<num, dynamic> {
extension GreaterThanValidation on LucidValidationBuilder<num, dynamic> {
/// Adds a validation rule that checks if the [num] is greater than [minValue].
///
/// [minValue] is the value that the number must be greater than.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [String] properties to add an empty string validation.
///
/// This extension adds an `isEmpty` method that can be used to ensure that a string
/// is empty.
extension IsEmptyValidator on LucidValidationBuilder<String, dynamic> {
extension IsEmptyValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the [String] is empty.
///
/// [message] is the error message returned if the validation fails. Defaults to "Must be empty".
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [T?] properties to add a not null validation.
///
/// This extension adds an `isNotNull` method that can be used to ensure that a value
/// is not null.
extension IsNotNullValidator<T, E> on LucidValidationBuilder<T?, E> {
extension IsNotNullValidation<T, E> on LucidValidationBuilder<T?, E> {
/// Adds a validation rule that checks if the value is not null.
///
/// [message] is the error message returned if the validation fails. Defaults to "Cannot be null".
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [T?] properties to add a null validation.
///
/// This extension adds an `isNull` method that can be used to ensure that a value
/// is null.
extension IsNullValidator<T, E> on LucidValidationBuilder<T?, E> {
extension IsNullValidation<T, E> on LucidValidationBuilder<T?, E> {
/// Adds a validation rule that checks if the value is null.
///
/// [message] is the error message returned if the validation fails. Defaults to "Must be null".
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [num] properties to add a less than validation.
///
/// This extension adds a `lessThan` method that can be used to ensure that a number
/// is less than a specified value.
extension LessThanValidator on LucidValidationBuilder<num, dynamic> {
extension LessThanValidation on LucidValidationBuilder<num, dynamic> {
/// Adds a validation rule that checks if the [num] is less than [maxValue].
///
/// [maxValue] is the value that the number must be less than.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [String] properties to add a regex pattern match validation.
///
/// This extension adds a `matchesPattern` method that can be used to ensure that a string
/// matches a specific regex pattern.
extension MatchesPatternValidator on LucidValidationBuilder<String, dynamic> {
extension MatchesPatternValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the [String] matches the [pattern].
///
/// [pattern] is the regex pattern that the string must match.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [String] properties to add a maximum length validation.
///
/// This extension adds a `maxLength` method that can be used to ensure that the length of a string
/// does not exceed a specified maximum number of characters.
extension MaxLengthValidator on LucidValidationBuilder<String, dynamic> {
extension MaxLengthValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the length of a [String] is less than or equal to [num].
///
/// [num] is the maximum allowed length for the string.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [num] properties to add a maximum value validation.
///
/// This extension adds a `max` method that can be used to ensure that a numerical value
/// does not exceed a specified maximum.
extension MaxValidator on LucidValidationBuilder<num, dynamic> {
extension MaxValidation on LucidValidationBuilder<num, dynamic> {
/// Adds a validation rule that checks if a [num] value is less than or equal to [num].
///
/// [num] is the maximum allowed value.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [String] properties to add a minimum length validation.
///
/// This extension adds a `minLength` method that can be used to ensure that the length of a string
/// meets a specified minimum number of characters.
extension MinLengthValidator on LucidValidationBuilder<String, dynamic> {
extension MinLengthValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the length of a [String] is greater than or equal to [num].
///
/// [num] is the minimum required length for the string.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [num] properties to add a minimum value validation.
///
/// This extension adds a `min` method that can be used to ensure that a numerical value
/// meets or exceeds a specified minimum.
extension MinValidator on LucidValidationBuilder<num, dynamic> {
extension MinValidation on LucidValidationBuilder<num, dynamic> {
/// Adds a validation rule that checks if a [num] value is greater than or equal to [num].
///
/// [num] is the minimum allowed value.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [String] properties to add a lowercase letter validation.
///
/// This extension adds a `mustHaveLowercase` method that can be used to ensure that a string
/// contains at least one lowercase letter.
extension MustHaveLowercase on LucidValidationBuilder<String, dynamic> {
extension MustHaveLowercaseValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the [String] contains at least one lowercase letter.
///
/// [message] is the error message returned if the validation fails. Defaults to "Must contain at least one lowercase letter".
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [String] properties to add a numeric character validation.
///
/// This extension adds a `mustHaveNumbers` method that can be used to ensure that a string
/// contains at least one numeric digit.
extension MustHaveNumbers on LucidValidationBuilder<String, dynamic> {
extension MustHaveNumbersValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the [String] contains at least one numeric digit.
///
/// [message] is the error message returned if the validation fails. Defaults to "Must contain at least one numeric digit".
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [String] properties to add a special character validation.
///
/// This extension adds a `mustHaveSpecialCharacter` method that can be used to ensure that a string
/// contains at least one special character.
extension MustHaveSpecialCharacter on LucidValidationBuilder<String, dynamic> {
extension MustHaveSpecialCharacterValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the [String] contains at least one special character.
///
/// [message] is the error message returned if the validation fails. Defaults to "Must contain at least one special character".
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [String] properties to add an uppercase letter validation.
///
/// This extension adds a `mustHaveUppercase` method that can be used to ensure that a string
/// contains at least one uppercase letter.
extension MustHaveUppercase on LucidValidationBuilder<String, dynamic> {
extension MustHaveUppercaseValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the [String] contains at least one uppercase letter.
///
/// [message] is the error message returned if the validation fails. Defaults to "Must contain at least one uppercase letter".
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [String] properties to add a not empty validation.
///
/// This extension adds a `notEmpty` method that can be used to ensure that a string
/// is not empty.
extension NotEmptyValidator on LucidValidationBuilder<String, dynamic> {
extension NotEmptyValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the [String] is not empty.
///
/// [message] is the error message returned if the validation fails. Defaults to "Cannot be empty".
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [T] properties to add a non-equality validation.
///
/// This extension adds a `notEqualTo` method that can be used to ensure that a value
/// is not equal to a specific value.
extension NotEqualValidator<T, E> on LucidValidationBuilder<T, E> {
extension NotEqualValidation<T, E> on LucidValidationBuilder<T, E> {
/// Adds a validation rule that checks if the value is not equal to [comparison].
///
/// [predicate] is the value that the field must not match.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [num] properties to add a range validation.
///
/// This extension adds a `range` method that can be used to ensure that a number
/// is within a specified range.
extension RangeValidator on LucidValidationBuilder<num, dynamic> {
extension RangeValidation on LucidValidationBuilder<num, dynamic> {
/// Adds a validation rule that checks if the [num] is within the range of [min] and [max].
///
/// [min] and [max] define the acceptable range for the number.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
part of 'validators.dart';
part of 'validations.dart';

extension ValidCEPValidator on LucidValidationBuilder<String, dynamic> {
extension ValidCEPValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the [String] is a valid CEP (Brazilian postal code).
///
/// This method verifies that the CEP is in the correct format (#####-###) and consists
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
part of 'validators.dart';
part of 'validations.dart';

extension ValidCNPJValidator on LucidValidationBuilder<String, dynamic> {
extension ValidCnpjValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the [String] is a valid CNPJ number.
///
/// The CNPJ is the national identifier for Brazilian companies. This method
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [String] properties to add a valid CPF validation.
///
/// This extension adds a `validCPF` method that can be used to ensure that a string
/// is a valid CPF number.
extension ValidCPFValidator on LucidValidationBuilder<String, dynamic> {
extension ValidCPFValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the [String] is a valid CPF number.
///
/// [message] is the error message returned if the validation fails. Defaults to "Invalid CPF".
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
part of 'validators.dart';
part of 'validations.dart';

extension ValidCreditCardValidator on LucidValidationBuilder<String, dynamic> {
extension ValidCreditCardValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the [String] is a valid credit card number.
///
/// This method uses the Luhn algorithm to verify the validity of a credit card number.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'validators.dart';
part of 'validations.dart';

/// Extension on [LucidValidationBuilder] for [String] properties to add a valid email validation.
///
/// This extension adds a `validEmail` method that can be used to ensure that a string
/// is a valid email address.
extension ValidEmailValidator on LucidValidationBuilder<String, dynamic> {
extension ValidEmailValidation on LucidValidationBuilder<String, dynamic> {
/// Adds a validation rule that checks if the [String] is a valid email address.
///
/// [message] is the error message returned if the validation fails. Defaults to "Invalid email address".
Expand Down
25 changes: 25 additions & 0 deletions lib/src/validations/validations.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import '../../lucid_validation.dart';

part 'equal_validation.dart';
part 'greater_than_validation.dart';
part 'is_empty_validation.dart';
part 'is_not_null_validation.dart';
part 'is_null_validation.dart';
part 'less_then_validation.dart';
part 'matches_pattern_validation.dart';
part 'max_length_validation.dart';
part 'max_validation.dart';
part 'min_length_validation.dart';
part 'min_validation.dart';
part 'must_have_lowercase_validation.dart';
part 'must_have_numbers_validation.dart';
part 'must_have_special_character_validation.dart';
part 'must_have_uppercase_validation.dart';
part 'not_empty_validation.dart';
part 'not_equal_validation.dart';
part 'range_validation.dart';
part 'valid_cep_validation.dart';
part 'valid_cnpj_validation.dart';
part 'valid_cpf_validation.dart';
part 'valid_creditcard_validation.dart';
part 'valid_email_validation.dart';
Loading

0 comments on commit 48d1f73

Please sign in to comment.