cpf_cnpj_validator 1.0.1

  • README.md
  • Installing
  • Versions
  • 86

CPF/CNPJ Validator #

A Flutter plugin to validate CPF/CNPJ numbers from Brazil.

pub package

Installation #

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

  cpf_cnpj_validator: "^1.0.0"

Usage CPF #

// Import package  
import 'package:cpf_cnpj_validator/cpf_validator.dart';  
CPFValidator.isValid("334.616.710-02") // true
CPFValidator.isValid("334.616.710-01") // false
CPFValidator.isValid("35999906032") // true
CPFValidator.isValid("35999906031") // false
CPFValidator.isValid("033461671002") // false

// Other utility methods
CPFValidator.format("33461671002") // Result: 334.616.710-02
CPFValidator.strip("334.616.710-02") // Result: 33461671002

// Generate a raw CPF number, without format
CPFValidator.generate() // Result: 33461671002

// Generate a formatted CPF number
CPFValidator.generate(true) // Result: 334.616.710-02 

Usage CNPJ #

// Import package  
import 'package:cpf_cnpj_validator/cnpj_validator.dart';  
CNPJValidator.isValid("12.175.094/0001-19") // true
CNPJValidator.isValid("12.175.094/0001-18") // false
CNPJValidator.isValid("17942159000128") // true
CNPJValidator.isValid("17942159000127") // false
CNPJValidator.isValid("017942159000128") // false

// Other utility methods
CNPJValidator.format("85137090000110") // Result: 85.137.090/0001-10
CNPJValidator.strip("85.137.090/0001-10") // Result: 85137090000110

// Generate a raw CNPJ number, without format
CNPJValidator.generate() // Result: 85137090000110

// Generate a formatted CNPJ number
CNPJValidator.generate(true) // Result: 85.137.090/0001-10 

Credits #

This plugin is a rewrite to Dart from an existing Javascript project with the same purpose. All the credits go to the person who created the projects in Javascript.

If you guys like this plugin, make sure to star the original projects. I'll leave the links below:



Contributing #

If you wish to contribute to this project, I encourage you to open a pull request.

v1.0.0 #

This release includes:

  • Ability to validate CPF and CNPJ numbers.
  • Ability to format, strip and create random CPF and CNPJ numbers.

v1.0.1 #

  • Fixing README.md

Use this package as a library

1. Depend on it

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

  cpf_cnpj_validator: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:cpf_cnpj_validator/cnpj_validator.dart';
import 'package:cpf_cnpj_validator/cpf_validator.dart';
Version Uploaded Documentation Archive
1.0.5 Feb 19, 2019 Go to the documentation of cpf_cnpj_validator 1.0.5 Download cpf_cnpj_validator 1.0.5 archive
1.0.4 Jan 1, 2019 Go to the documentation of cpf_cnpj_validator 1.0.4 Download cpf_cnpj_validator 1.0.4 archive
1.0.3 Jan 1, 2019 Go to the documentation of cpf_cnpj_validator 1.0.3 Download cpf_cnpj_validator 1.0.3 archive
1.0.2 Dec 31, 2018 Go to the documentation of cpf_cnpj_validator 1.0.2 Download cpf_cnpj_validator 1.0.2 archive
1.0.1 Dec 31, 2018 Go to the documentation of cpf_cnpj_validator 1.0.1 Download cpf_cnpj_validator 1.0.1 archive
1.0.0 Dec 31, 2018 Go to the documentation of cpf_cnpj_validator 1.0.0 Download cpf_cnpj_validator 1.0.0 archive
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 May 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.0
  • pana: 0.12.15
  • Flutter: 1.5.8


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

18 out of 18 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/cnpj_validator.dart.

Run flutter format to format lib/cnpj_validator.dart.

Format lib/cpf_validator.dart.

Run flutter format to format lib/cpf_validator.dart.

Maintenance suggestions

The package description is too short. (-20 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.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and cpf_cnpj_validator.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
flutter_test 0.0.0
Transitive dependencies
async 2.1.0 2.2.0
boolean_selector 1.0.4
charcode 1.1.2
collection 1.14.11
matcher 0.12.5
meta 1.1.6 1.1.7
path 1.6.2
pedantic 1.5.0 1.6.0
quiver 2.0.2 2.0.3
sky_engine 0.0.99
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
string_scanner 1.0.4
term_glyph 1.1.0
test_api 0.2.4 0.2.5
typed_data 1.1.6
vector_math 2.0.8