Skip to content

Instantly share code, notes, and snippets.

@Giorgiosaud
Last active August 30, 2021 14:01
Show Gist options
  • Select an option

  • Save Giorgiosaud/07bfacf10214145ada0d9b3096062f9e to your computer and use it in GitHub Desktop.

Select an option

Save Giorgiosaud/07bfacf10214145ada0d9b3096062f9e to your computer and use it in GitHub Desktop.
const validator = {
getMessage(field, args) {
return `The field ${field} is not a valid RUT`;
},
validate(value, args) {
const toValidate=value.slice(-1).toUpperCase();
let validador=11-rut.toString().split('').reverse().reduce((sum,el,i)=>sum+=el*(i%6+2),0)%11;
validador==10?'K':validador;
return validador===toValidate;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment