Ir para conteúdo

Bem vindo ao Fluttership

Fluttership

Entre para seguir isso  
Crow

flutter cpf_cnpj_validator

Recommended Posts

Adiciona no pubspec.yaml

dependencies:
  cpf_cnpj_validator: ^1.0.5

Pra usar 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 

Pra usar 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 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
5 horas atrás, Crow disse:

Adiciona no pubspec.yaml


dependencies:
  cpf_cnpj_validator: ^1.0.5

Pra usar 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 

Pra usar 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 

 

Qual diferença entre 

334.616.710-02

 

334.616.710-01

?

ele consome alguma api ?

Compartilhar este post


Link para o post
Compartilhar em outros sites
Em 14/09/2019 at 20:13, Alex Castro disse:

Qual diferença entre 


334.616.710-02

 


334.616.710-01

?

ele consome alguma api ?

Alex para validar CPF e CNPJ existe um algorítimo para fazer a validação segue um site que ensina como e feito a conta. Link

Compartilhar este post


Link para o post
Compartilhar em outros sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Visitante
Responder

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Entre para seguir isso  

×
×
  • Criar Novo...