import { mod11 } from './mod11' ; param value returns export function validateCNPJ ( value ) { const clearValue = String ( value ) . replace ( /[^\d]+/g , '' ) ; if ( clearValue === '' ) return false ; if ( clearValue . length !== 14 ) return false ; if ( clearValue === '00000000000000' || clearValue === '11111111111111' || clearValue === '22222222222222' || clearValue === '33333333333333' || clearValue === '44444444444444' || clearValue === '55555555555555' || clearValue === '66666666666666' || clearValue === '77777777777777' || clearValue === '88888888888888' || clearValue === '99999999999999' ) { return false ; } const valWithoutDvs = clearValue . substring ( 0 , clearValue . length - 2 ) ; const dv1 = mod11 ( valWithoutDvs , 9 ) ; const dv2 = mod11 ( valWithoutDvs + dv1 , 9 ) ; return valWithoutDvs + dv1 + dv2 === clearValue ; }