Closed IncognitaDev closed 3 years ago
already exists,
import { cpf } from 'cpf-cnpj-validator';
const num = cpf.generate();
// #=> 25634428777
cpf.format(num); // <----- here!!
// #=> 256.344.287-77
this function aplly format, I sugested a function that removes format
I understand, this is an accessory feature. A very simple regex can be used to test.
const removeMask = (value) => {
return value && value.replace(/[^\w\s]/gi, '')
}
removeMask('725.428.702-72')
// #=> "72542870272"
removeMask('33.057.042/0001-00')
// #=> "33057042000100"
but in this case we are removing all special characters and it could also be any string.
Should we leave the treatment open for any string or, treat only number of valid documents to have a more specific regex?
I found the idea interesting, I'll check the best way to add it...
I'm ending this problem for now
I think this module can contain a unformat function to remove dots and others non number characters.