form_validations_kit 0.0.5 copy "form_validations_kit: ^0.0.5" to clipboard
form_validations_kit: ^0.0.5 copied to clipboard

A simple, reusable, and production-ready form validation package for Flutter.

form_validations_kit

Rule-based • Testable • No UI dependency • Flutter


🚀 Overview #

form_validations_kit is a lightweight, reusable, and production-ready
form validation engine for Flutter.

It helps you keep validation logic:

  • clean
  • reusable
  • testable
  • independent from UI

No more duplicated validators across screens.


✨ Features #

  • ✅ Rule-based validation engine
  • 📧 Email validation
  • 🔐 Password strength rules
  • 🔁 Confirm password matching
  • 📞 Phone & numeric validation
  • ⚡ Fast-exit validation (first error only)
  • 🧪 Pure Dart, easy to test
  • 🎯 No UI dependency

📱 Platform Support #

Platform Supported
Android
iOS
Web
Windows
macOS
Linux

🎬 Example App #


📦 Installation #

Add this to your pubspec.yaml:

dependencies:
  form_validations_kit: ^0.0.5

Then run:

  flutter pub get


## Usage

Designed to work seamlessly with Flutter Form and TextFormField.

### Required Field

Ensures the field is not empty.

```dart
TextFormField(
  validator: (value) => EasyFormValidator.validate(
    value,
    rules: [Rules.required()],
  ),
);

### Email Validation

Ensures the field is not empty.

```dart
TextFormField(
  keyboardType: TextInputType.emailAddress,
  validator: (value) => EasyFormValidator.validate(
    value,
    rules: [
      Rules.required(),
      EmailRules.email(),
    ],
  ),
);

### Password Validation

Ensures the field is not empty.

```dart
TextFormField(
  obscureText: true,
  validator: (value) => EasyFormValidator.validate(
    value,
    rules: [
      PasswordRules.minLength(8),
      PasswordRules.hasUppercase(),
      PasswordRules.hasNumber(),
      PasswordRules.hasSpecialChar(),
    ],
  ),
);

### Confirm Password Validation

Ensures the field is not empty.

```dart
TextFormField(
  obscureText: true,
  validator: (value) => EasyFormValidator.validate(
    value,
    rules: [
      Rules.required(),
      Rules.match(passwordController.text),
    ],
  ),
);


### Phone Number Validation

Ensures the field is not empty.

```dart
TextFormField(
  keyboardType: TextInputType.phone,
  validator: (value) => EasyFormValidator.validate(
    value,
    rules: [
      Rules.required(),
      NumberRules.phone(),
    ],
  ),
);

### Validate an Entire Form

Ensures the field is not empty.

```dart
final _formKey = GlobalKey<FormState>();

Form(
  key: _formKey,
  child: Column(
    children: [
      // form fields
      ElevatedButton(
        onPressed: () {
          if (_formKey.currentState!.validate()) {
            print('Form is valid 🎉');
          }
        },
        child: const Text('Submit'),
      ),
    ],
  ),
);
0
likes
160
points
169
downloads

Publisher

unverified uploader

Weekly Downloads

A simple, reusable, and production-ready form validation package for Flutter.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on form_validations_kit