flutter_validation

Last updated:

0 purchases

flutter_validation Image
flutter_validation Images
Add to Cart

Description:

flutter validation

Description #
This package provides a set of commonly used validation functions for form fields in Flutter applications.
Examples #



Email


Required


Strong Password


Combined Required and Email



















Phone


Maximum Length 16


Combined Email and Phone














and many more.
Salient Features #

Required field validation: Checks if a field is empty.
Email validation: Validates email addresses based on a regular expression.
Phone number validation: Basic phone number validation.
Alphanumeric validation: Allows only letters and numbers.
Password strength validation: Checks for uppercase, lowercase, digits, and special characters (customizable).
Minimum and maximum length validation: Enforces minimum and maximum character lengths for a field.
Combined phone/email validation: Allows users to enter either a valid phone number or email address.
Combine multiple validators: Combine multiple validators for complex validations.

Installation #
dependencies:
flutter_validations: ^0.0.2

copied to clipboard
Available Validators #

requiredValidator: Checks if a field is empty.
emailValidator: Validates email addresses.
phoneValidator: Basic phone number validation. (Can be extended)
alphanumericValidator: Allows only letters and numbers.
upperCaseValidator: Checks for uppercase letters in password.
lowerCaseValidator: Checks for lowercase letters in password.
digitValidator: Checks for digits in password.
specialCharValidator: Checks for special characters in password.
maxLengthValidator: Enforces a maximum character length.
minLengthValidator: Enforces a minimum character length.
combinedPhoneEmailValidator: Allows either phone number or email.
combineValidators: Combines multiple validators.

Usage #
Using Flutter_validation
Use Validators class with it's functions like this,
Required validator:
Using Validators().requiredValidator();
TextFormField(
autovalidateMode: AutovalidateMode.onUserInteraction,
controller: firstNameController,
validator: (value) =>
Validators().requiredValidator(
errorMessage: 'This field must not be empty.',
value: value
),
),
copied to clipboard
Email validator:
Using Validators().emailValidator();
TextFormField(
autovalidateMode: AutovalidateMode.onUserInteraction,
controller: firstNameController,
validator: (value) =>
Validators().emailValidator(
errorMessage: 'Please enter valid email address.',
value: value
),
),
copied to clipboard
Combine validator:
Using Validate.combineValidators();
TextFormField(
autovalidateMode: AutovalidateMode.onUserInteraction,
controller: firstNameController,
validator: (value) =>
Validators().combineValidators(
validators: [
Validators().requiredValidator(errorMessage: 'Username must not be empty.', value: value),
Validators().minLengthValidator(minLength: 3,errorMessage: 'Please enter a username with at least 3 characters.', value: value),
Validators().upperCaseValidator(errorMessage: 'Username must contain atleast 1 uppercase letter',value: value),

]
),
),
copied to clipboard
Note: In combine validators you have to pass value for each validator.
Alphanumeric validator:
Using Validate.alphanumericValidator();
TextFormField(
autovalidateMode: AutovalidateMode.onUserInteraction,
controller: firstNameController,
validator: (value) =>
validator: (value) => Validators().alphanumericValidator(value: value,),
// this will return "Please enter only letters and numbers" vaildation error
),
copied to clipboard
Info #
Feel Free to request any missing features or report issues here.
License #
MIT License

Copyright (c) 2024 Nichetechsolutions

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.