Skip to content

ValidasiType-Safe Validation for Dart & Flutter

A flexible, composable, and type-safe validation library that makes data validation elegant and effortless

Validasi Logo

Quick Example ​

Get started with Validasi in seconds:

dart
import 'package:validasi/validasi.dart';
import 'package:validasi/rules.dart';

// Define your validation schema
final userSchema = Validasi.map<dynamic>([
  MapRules.hasFields({
    'name': Validasi.string([
      StringRules.minLength(2),
      StringRules.maxLength(50),
    ]),
    'email': Validasi.string([
      StringRules.email(),
    ]),
    'age': Validasi.number<int>([
      NumberRules.moreThanEqual(18),
      NumberRules.lessThan(100),
    ]),
  }),
]);

// Validate your data
final result = userSchema.validate({
  'name': 'John Doe',
  'email': 'john@example.com',
  'age': 25,
});

if (result.isValid) {
  print('Validation passed! Data: ${result.data}');
} else {
  print('Errors: ${result.errors.map((e) => e.message)}');
}

Why Validasi? ​

Elegant API Design

Validasi provides an intuitive, fluent API that makes validation code readable and maintainable. No more messy validation logic scattered throughout your codebase.

Production Ready

Battle-tested in production applications. Validasi handles edge cases gracefully and provides clear error messages for better debugging.

Performance Matters

With built-in caching and optimization, Validasi is designed for high-performance scenarios where validation speed is critical.

Installation ​

Add Validasi to your pubspec.yaml:

yaml
dependencies:
  validasi: ^1.0.0-dev.0

Then run:

bash
dart pub get
# or for Flutter
flutter pub get

Ready to dive deeper? ​

Released under the MIT License.