simple-react-validator icon indicating copy to clipboard operation
simple-react-validator copied to clipboard

Custom Locale is not working.

Open prince17dec opened this issue 2 years ago • 0 comments

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>

prince17dec avatar Oct 11 '22 07:10 prince17dec