Skip to content

Commit

Permalink
Campo validação com as classes do material
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielFaria committed Mar 16, 2018
1 parent 22ab858 commit 8124a23
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/components/comum/campoTexto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ const renderCampoTexto = ({
type,
meta: { touched, error, warning },
divClasse, id, onChange, inputClasse, maxLen, placeholder
}) => (
<div className={divClasse}>
<input
id={id}
{...input}
type={type}
className={inputClasse}
maxLength={maxLen}
placeholder={placeholder || undefined}
/>
<label className="active" htmlFor={id}>{label}</label>
{ touched && error && <span>{error}</span>}
</div>
)
}) => {
const existeErroDeValidacao = touched && error;
return (
<div className={divClasse}>
<input
id={id}
{...input}
type={type}
className={ !existeErroDeValidacao? inputClasse :inputClasse+' '+'invalid'}
maxLength={maxLen}
placeholder={placeholder || undefined}
/>
<label className="active" data-error={error} data-success="right" htmlFor={id}>{label}</label>
</div>)
}



Expand Down

0 comments on commit 8124a23

Please sign in to comment.