cpf_cnpj_validator 1.0.5

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 92

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:

dependencies:
  cpf_cnpj_validator: ^1.0.5

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

// If you dont want the validation method to strip the values
// Just use false in the second argument
CPFValidator.isValid("334.616.710-02", false) // false
CPFValidator.isValid("35999906032@mail", false) // 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

// If you dont want the validation method to strip the values
// Just use false in the second argument
CNPJValidator.isValid("12.175.094/0001-19", false) // false
CNPJValidator.isValid("17942159000128@mail", false) // 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:

https://github.com/fnando/cpf

https://github.com/fnando/cnpj

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

v1.0.2 #

  • Fixing README.md

v1.0.3 #

  • Fixing README.md

v1.0.4 #

  • Adding Example
  • Changing description

v1.0.5 #

  • Adding new parameter to control whether or not the validation method should strip the values

example/README.md

example #

An example of how to use Flutter plugin CPF/CNPJ validator.

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:


dependencies:
  cpf_cnpj_validator: ^1.0.5

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: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
Popularity:
Describes how popular the package is relative to other packages. [more]
85
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
92
Learn more about scoring.

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

  • Dart: 2.3.1
  • pana: 0.12.17
  • Flutter: 1.5.4-hotfix.2

Platforms

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/cpf_validator.dart.

Run flutter format to format lib/cpf_validator.dart.

Dependencies

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.7.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.6
typed_data 1.1.6
vector_math 2.0.8