validators 2.0.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

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]
74
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
84
Overall:
Weighted score of the above. [more]
88
Learn more about scoring.

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

  • Dart: 2.6.1
  • pana: 0.13.1+4

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.

Dependencies

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