auto_validate
Auto Validate 套件透過使用可自訂的正則表達式來簡化輸入驗證,進而能有效驗證各種資料格式。
dev-mahmoud-elshenawy/auto_validate open-source repository details.
以下為英文專案原文快照,最新內容請造訪 GitHub。
The Auto Validate Package is a unique and easy-to-use solution for automatic validation of various data types using regular expressions.
This package streamlines the validation process, allowing you to easily implement validation without needing to write the code yourself. By using this package, you can save valuable time and ensure that your input data meets the required criteria.
Here's a simple example of how to use the Auto Validate package:
This package provides an extension on String? that offers convenient methods for validating various input formats using the AutoValidate class. It allows for a more readable and fluent validation process in your Dart applications.
String? instances.import 'package:auto_validate/auto_validate.dart';
void validation() {
var email = 'Dev.M.ElShenawy@Icloud.com';
var name = 'Mahmud El Shenawy';
var password = '@MahmoudElShenawy2021';
var phone = '+201098415860';
// You can validate the input using the AutoValidate class
AutoValidate.email(email.toString())
? print('Email is Valid')
: print('Email is Invalid');
AutoValidate.userName(name.toString())
? print('User Name is Valid')
: print('User Name is Invalid');
AutoValidate.password(password.toString())
? print('Password is Valid')
: print('Password is Invalid');
AutoValidate.phone(phone.toString())
? print('Phone is Valid')
: print('Phone is Invalid');
// You can also use the extension methods to validate the input
email.isValidEmail
? print('Email is Valid')
: print('Email is Invalid');
name.isValidUsername
? print('User Name is Valid')
: print('User Name is Invalid');
password.isValidPassword
? print('Password is Valid')
: print('Password is Invalid');
phone.isValidPhone
? print('Phone is Valid')
: print('Phone is Invalid');
}
A simple usage of Form Validator Example:
import 'package:auto_validate/auto_validate.dart';
TextFormField(
controller: emailController,
decoration: InputDecoration(
hintText: "Email",
border: OutlineInputBorder(
borderSide: BorderSide(),
),
),
validator: FormValidator.email(
errorMessage: 'Please Enter Valid Email',
),
);
Make validation on all next elements with AutoValidate
Make form validation on all next elements with FormValidator
import 'package:auto_validate/auto_validate.dart';
TextFormField(
controller: emailController,
decoration: InputDecoration(
hintText: "Password",
border: OutlineInputBorder(
borderSide: BorderSide(),
),
),
validator: FormValidator.combination(
validators: [
FormValidator.maxLength(maxLength: 15, errorMessage: 'Password Enter Valid Password With Max Length 15'),
FormValidator.minLength(minLength: 5, errorMessage: 'Password Enter Valid Password At Least Min Length 5'),
FormValidator.passwordStrong(errorMessage: 'Please Enter Valid Strong Password')
])
);
If you encounter any issues, bugs, or have suggestions for improvements, please report them on the GitHub Issues page.
When reporting an issue, please provide the following information:
Your feedback is invaluable for improving the package and helping others in the community!
This project is licensed under the MIT License - see the LICENSE file for details
依賴清單 3 項
{"sdk":"flutter"}^1.19.1{"sdk":"flutter"}先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗