import isCPF , { CPF_PATTERN } from "./isCPF" ; import isCNPJ , { CNPJ_PATTERN } from "./isCNPJ" ; const PATTERNS = [ CPF_PATTERN , CNPJ_PATTERN ] ; example param value const isCPFOrCNPJ = ( value ) : boolean => { const matches = PATTERNS . map ( ( pattern ) => pattern . test ( value ) ) ; if ( ! matches . includes ( true ) ) return false ; return matches [ 0 ] ? isCPF ( value ) : isCNPJ ( value ) ; } ; export default isCPFOrCNPJ ;