smart_validator 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 76

English | 简体中文

smart_validator #

pub package

A string or numeric validator for flutter,Including email, phone and so on

Usage #

To use this plugin, add smart_validator as a dependency in your pubspec.yaml file.

Example #

// Import package
import 'package:smart_validator/smart_validator.dart';

 Validator validator = Validator(rules: {
    "param1": [
      Required(message: "param1不能为空"), /// or  Required(message: ()=>"param1不能为空")
      Number(message: "param1必须是数字"), /// or  Number(message: ()=>"param1必须是数字")
      Range(max: Section(value: 10), min: Section(value: 1), message: "param1必须在1到10之间")
      /// or  Range(max: Section(value: ()=>10), min: Section(value: ()=>1), message: "param1必须在1到10之间")

   print(validator.validate("param1", ""));
   // ValidResult{ pass: false, message: param1不能为空, filteredMsg: param1不能为空 }

   print(validator.validate("param1", "sdfsf"));
    // ValidResult{ pass: false, message: param1必须是数字, filteredMsg: param1必须是数字 }

   print(validator.validate("param1", "20"));
   // ValidResult{ pass: false, message: param1必须在1到10之间, filteredMsg: param1必须在1到10之间 }

   print(validator.validate("param1", "5"));
   // ValidResult{ pass: true, message: param1必须在1到10之间, filteredMsg:  }

[0.1.0] - 2019/11/20

  • Validator添加validateFormField方法方便Flutter TextFormField的验证

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.


example #

A new Flutter application.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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

  smart_validator: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support 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:smart_validator/smart_validator.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 Jan 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Fix lib/smart_validator.dart. (-1.49 points)

Analysis of lib/smart_validator.dart reported 3 hints:

line 3 col 8: Unused import: 'package:flutter/cupertino.dart'.

line 280 col 17: The value of the field '_value' isn't used.

line 296 col 17: The value of the field '_value' isn't used.

Format lib/validator_tag.dart.

Run flutter format to format lib/validator_tag.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies