import { mod11 } from './mod11' ; param ref returns const isRepeated = ( ref ) => { const ret = ref . replace ( new RegExp ( ref [ 0 ] , 'g' ) , '' ) . trim ( ) . length === 0 ; return ret ; } ; param value export function validateCPF ( value ) { const clearValue = String ( value ) . replace ( /\D/g , '' ) ; const valWithoutDvs = clearValue . substring ( 0 , clearValue . length - 2 ) ; if ( ! clearValue || isRepeated ( clearValue ) ) { return false ; } const dv1 = mod11 ( valWithoutDvs , 12 ) ; const dv2 = mod11 ( valWithoutDvs + dv1 , 12 ) ; return valWithoutDvs + dv1 + dv2 === clearValue ; }