Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation for special characters #167

Open
luizeduardofs opened this issue Feb 2, 2025 · 1 comment
Open

Validation for special characters #167

luizeduardofs opened this issue Feb 2, 2025 · 1 comment
Assignees
Labels
feature request Proposals for new features

Comments

@luizeduardofs
Copy link

Is your feature request related to a problem? Please describe.

Validation for passwords and other fields that require special characters is an increasing need in many authentication and security systems. Currently, Vania Dart does not provide a direct way to validate if a field contains specific special characters (like @, $, %, etc.), which makes it difficult to implement stronger security requirements. This has caused frustration when trying to validate passwords and user data that require this feature efficiently.

Describe the solution you'd like

I would like Vania Dart to add a dedicated validation rule for special characters. This would allow developers to easily validate passwords and other fields that require one or more special characters, without the need to manually use regular expressions. A native solution, such as a pattern validation or a special_characters rule, would be ideal.

Describe alternatives you've considered

An alternative that has been used is implementing manual validation through regular expressions, such as using pattern:(?=.[@$!%#?&]) to validate passwords with special characters. While this works, creating a native validation rule in Vania Dart would be a cleaner and more practical approach, without the need for regex in every case.

Additional context

Adding a special character validation directly to Vania Dart would help improve application security and developer experience, enabling the implementation of stricter rules in a simple and hassle-free way.

@luizeduardofs luizeduardofs added the feature request Proposals for new features label Feb 2, 2025
@luizeduardofs luizeduardofs changed the title [Feature Request] - Brief Description of Feature Validation for special characters Feb 2, 2025
@javad-zobeidi javad-zobeidi self-assigned this Feb 3, 2025
javad-zobeidi added a commit to javad-zobeidi/framework that referenced this issue Feb 3, 2025
@javad-zobeidi
Copy link
Collaborator

@luizeduardofs

Please update to version 0.8.0. You can use RegExp as follows:

req.validate({
  'username': r'reg_exp:^[a-zA-Z]+$',
});

Alternatively, you can create a custom rule:

*Note: the ruleName must be in lowercase

req.setCustomRule([
  CustomValidationRule(
    ruleName: 'unique_user',
    message: 'User already exists',
    fn: (Map<String, dynamic> data, dynamic value, String? arguments) {
      return true;
    },
  ),
]).validate({
  'username': 'unique_user',
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Proposals for new features
Projects
None yet
Development

No branches or pull requests

2 participants