vguard 1.0.3 copy "vguard: ^1.0.3" to clipboard
vguard: ^1.0.3 copied to clipboard

A simple and fluent way to validate form or input data in Dart and Flutter.

VGuard #

VGuard is a lightweight and fluent validation library for Dart and Flutter, designed to simplify input validations through a chainable API.

๐Ÿš€ Getting Started #

a) Adding the package to your pubspec.yaml #

dependencies:
  vguard: ^1.0.0

b) Or add via Dart CLI: #

dart pub add vguard

Once added, import the package in your Dart or Flutter file:

import 'package:vguard/src/utils/extensions.dart';

๐Ÿงช How To Use #

Basic Example #

final result = ValidationChain("email@example.com")
  .isRequired()
  .isEmail()
  .run();

if (!result.isValid) {
  print(result.errors);
}

Password Validation #

final result = ValidationChain("MyStrong@Pass123")
  .isSecurePassword(highSecurityValidation: true)
  .run();

if (!result.isValid) {
  print(result.errors);
}

๐Ÿ”ง Available Validators #

You can build custom validation chains with any of the following validators:

Validator Description
isRequired() Ensures the value is not null or empty
isEmail() Validates if the value is a properly formatted email
isMinimumLength(n) Validates that the value has at least n characters
isMaximumLength(n) Validates that the value has at most n characters
isSecurePassword() Validates password strength (standard or strict mode based on your needs)

๐Ÿ’ก Validation Result #

The result of the validation is an instance of ValidationResult, which includes:

bool isValid;
List<String> errors;

Use isValid to check the result and errors to get the list of failed messages.

๐Ÿ“‚ Example #

You can find more examples in the example folder.

๐Ÿงฉ Contributing #

Contributions are welcome and appreciated!

If you have ideas, bugs to report, or features to suggest:

  • Open an issue with an appropriate label.
  • Follow Conventional Commits and Semantic Versioning for PRs.
  • Don't forget to star the project!

๐Ÿ“ฌ Contact #

Maintainer: devv-thiago

๐Ÿ™Œ Acknowledgements #

Inspired by clean, expressive, and maintainable validation APIs.

5
likes
160
points
33
downloads

Publisher

unverified uploader

Weekly Downloads

A simple and fluent way to validate form or input data in Dart and Flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on vguard