validators 2.0.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 87

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:

  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


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

main() {
  print(trim('  hello '));

  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:

  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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

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

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

line 5 col 17: Unnecessary new keyword.

line 8 col 21: Unnecessary new keyword.

line 9 col 16: Unnecessary new keyword.

line 11 col 32: Unnecessary new keyword.

line 13 col 17: Unnecessary new keyword.

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

Analysis of lib/sanitizers.dart reported 15 hints, including:

line 9 col 42: Use isEmpty instead of length

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

line 64 col 38: Unnecessary new keyword.

line 64 col 77: Unnecessary new keyword.

line 70 col 33: Unnecessary new keyword.

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

Analysis of lib/src/helpers.dart reported 2 hints:

line 4 col 7: Use isNotEmpty instead of length

line 14 col 11: Unnecessary new keyword.

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.

Package is getting outdated. (-5.48 points)

The package was last published 55 weeks ago.


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