Skip to content
pubscout

string_validator

1.2.0, released a year ago by suragch.dev

String validation and sanitization library for Dart.

WASM-ready
$ flutter pub add string_validator
Source repository

What it does

Provides a comprehensive set of string validation and sanitization functions, such as checking for email formats, URLs, numeric values, and cleaning or escaping string inputs. It also supports extension methods to call these functions directly on string instances.

AI-written summary of version 1.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to validate user inputs like emails, URLs, or specific formats.
  • You want to sanitize and clean strings before processing or storing them.

Skip it when

  • You are building complex multi-field form validation schemas that require form state management.
  • You need specific UI text field masking inputs.

Strengths

  • Extensive collection of validators and sanitizers ported from validator.js.
  • Convenient extension methods for direct usage on String instances.
  • No external dependencies and supports all platforms.

Weaknesses

  • Does not integrate directly into Flutter's Form/FormField validation state out of the box without manual callbacks.
  • Limited to string operations only.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:string_validator/string_validator.dart';

void main() {
  String email = 'example@gmail.com';
  bool isEmailValid = email.isEmail;

  String url = 'https://example.com';
  bool isUrlValid = url.isURL();
}

Alternatives

Packages that do the same job and could replace string_validator.

  • email_validator

    Pick this alternative if you specifically only need robust email address validation.

  • formz

    Pick this alternative if you need robust standalone form validation models with status handling.

Works with

Packages commonly used together with string_validator: ones it builds on, ones built on it, and its own family.