{"size": 561, "ext": "js", "max_stars_repo_path": "src/validate/JsBrazilValidate.js", "max_stars_repo_name": "mariohmol/vue-brazil", "max_stars_repo_stars_event_min_datetime": "2020-04-26T21:34:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-09T19:03:44.000Z", "max_issues_repo_path": "dist/validate/JsBrazilValidate.js", "max_issues_repo_name": "mariohmol/vue-brazil", "max_issues_repo_issues_event_min_datetime": "2020-01-09T13:25:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-03T18:29:47.000Z", "max_forks_repo_path": "src/validate/JsBrazilValidate.js", "max_forks_repo_name": "mariohmol/vue-brazil", "max_forks_repo_forks_event_min_datetime": "2020-10-01T18:37:16.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-31T00:30:53.000Z"}
{"max_stars_count": 11, "max_issues_count": 10, "max_forks_count": 2, "avg_line_length": 28.05, "max_line_length": 78, "alphanum_fraction": 0.5900178253}
import { validateBr } from "js-brasil";

const updateValue = (el, type) => {
  let value = el.value;  
  if(type && validateBr[type] ){
    return validateBr[type](value ? value.toString() : value);
  }
}

export default function JSBrazilValidate (e, errors = []){
    for (let item of e.target) {
        const type = item.getAttribute('data-brtype');
        const error = updateValue(item, type);
        if(!error){
            const name = item.getAttribute('id') || item.getAttribute('name');
            errors.push(name + ' inválido')
        }
    }
}
