validators2
5.1.1, released 3 weeks ago by onepub.dev
String validation and sanitization for Dart.
WASM-ready
What it does
Provides a collection of functions to validate common string patterns such as emails, URLs, IPs, and more. It also offers sanitization helpers to clean input strings.
AI-written summary of version 5.1.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need quick, reusable validation logic without external dependencies.
- You want to validate user input in forms or APIs.
- You need to sanitize strings before processing or storing them.
Skip it when
- You require advanced form building or UI integration; a dedicated form library would be better.
- You need localization or internationalization of validation messages.
- You need to generate validation code automatically.
Strengths
- No external dependencies, pure Dart.
- Up-to-date regexes and edge‑case handling (e.g., email backtracking fix).
- Supports Dart 3.x and null safety.
Weaknesses
- Limited to string validation; no UI components.
- No built‑in error message localization.
- Not a form builder, just helper functions.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:validators2/validators2.dart';
bool isValidEmail(String email) => isEmail(email);
String sanitized = sanitizeEmail(' user@example.com ');Alternatives
Packages that do the same job and could replace validators2.
- validators
Same functionality, older version; use if you need compatibility with older Dart SDKs.
50Compare
Works with
Packages commonly used together with validators2: ones it builds on, ones built on it, and its own family.