simple-react-validator
simple-react-validator copied to clipboard
Custom Locale is not working.
When I try to use locale which the library supports, the locale is not working for example for English I got the proper message. "The username field is required." but in the case of another language "Fält :attribut krävs.'," basically here field name is missing which is username.
Am using the Swedish locale.
import SimpleReactValidator from 'simple-react-validator';
import 'simple-react-validator/dist/locale/sv';
const validator = useRef(new SimpleReactValidator({locale: 'sv'}));
<label>
{t('username')}
<input
id="username"
type="text"
name="username"
value={username}
onChange={event => setUsername(event.target.value)}
onBlur={()=>validator.current.showMessageFor('username')}
/>
{validator.current.message('username', username, 'required|email')}
</label>