validators 2.0.0+1

validators #

Build Status

String validation and sanitization for Dart. Dart 2-compatible version of validator

Port of chriso's library.

Usage #

1. Add dependency to your package's pubspec.yaml file:

dependencies:
  validators: ^2.0.0 # change to latest version

2. Run from the command line:

$ pub get

Alternatively, your editor might support pub. Check the docs for your editor to learn more.

3. Import in your Dart code:

import 'package:validators/validators.dart';

Documentation #

Validators #

Sanitizers #

2.0.0 #

  • Change isUrl and isFQDN options parameter to be optional parameters

1.0.0 #

  • migrate to dart 2 and fix tests

example/main.dart

import 'package:validators/validators.dart';
import 'package:validators/sanitizers.dart';

main() {
  print(toString(1));
  print(trim('  hello '));
  print(toDouble('1.23'));

  print(isDate('1988-01-01'));
  print(isNumeric('123'));
  print(isAlphanumeric('abc123'));
  print('isUrl: ${isURL('example', requireTld: false)}');
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  validators: ^2.0.0+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:validators/validators.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
97
Health:
Code health derived from static analysis. [more]
96
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
84
Overall:
Weighted score of the above. [more]
94
Learn more about scoring.

We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:validators/validators.dart.

Health suggestions

Fix lib/validators.dart. (-2.96 points)

Analysis of lib/validators.dart reported 6 hints, including:

line 48 col 10: Use contains instead of indexOf

line 77 col 22: Use isEmpty instead of length

line 87 col 9: Use contains instead of indexOf

line 192 col 9: Use isEmpty instead of length

line 206 col 59: Use contains instead of indexOf

Fix lib/sanitizers.dart. (-1 points)

Analysis of lib/sanitizers.dart reported 2 hints:

line 9 col 42: Use isEmpty instead of length

line 39 col 33: Use = to separate a named parameter from its default value.

Fix lib/src/helpers.dart. (-0.50 points)

Analysis of lib/src/helpers.dart reported 1 hint:

line 4 col 7: Use isNotEmpty instead of length

Maintenance suggestions

The package description is too short. (-16 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.3.3