Created
February 20, 2019 18:36
-
-
Save alobato/3f38b37b85ae86df6d7fa107043a0407 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const FormatCpf = props => { | |
| let formatedCpf = props.children | |
| if (!formatedCpf) return '' | |
| if (formatedCpf.length === 11) | |
| formatedCpf = `${formatedCpf.substr(0, 3)}.${formatedCpf.substr(3, 3)}.${formatedCpf.substr(6, 3)}-${formatedCpf.substr(9, 2)}` | |
| return formatedCpf | |
| } | |
| export const FormatCnpj = props => { | |
| let formated = props.children | |
| if (!formated) return '' | |
| if (formated.length === 14) | |
| formated = `${formated.substr(0, 2)}.${formated.substr(2, 3)}.${formated.substr(5, 3)}/${formated.substr(8, 4)}-${formated.substr(12, 2)}` | |
| return formated | |
| } | |
| export const FormatGender = props => { | |
| if (props.children && props.children.toString().toUpperCase() === 'M') return 'Masculino' | |
| if (props.children && props.children.toString().toUpperCase() === 'F') return 'Feminino' | |
| return '' | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment