Skip to content

v3.9.0

Compare
Choose a tag to compare
@akuzko akuzko released this 09 Apr 19:51
· 6 commits to master since this release

New Features

  • Added asynchronous validation functionality requested by @Swensson in #1 . The details on new feature can be read in README. A quick example:
defValidation('checkEmail', (value, { message }) => {
  if (!value) return;

  return apiClient.checkEmail(value)
    .then((data) => {
      if (!data.isValid) {
        return Promise.reject(message || data.message || 'This email cannot be used');
      }
    })
});

function UserForm() {
  const { $ } = useForm({
    initial: { email: '', fullName: '' },
    validations: {
      rules: {
        email: 'presence',
        fullName: 'presence'
      },
      async: {
        email: 'checkEmail'
      }
    }
  });
}