Skip to content

v0.7.0

Compare
Choose a tag to compare
@logaretm logaretm released this 08 Feb 18:14
· 36 commits to main since this release

   🚀 Features

  • Expose getError, getValue, getErrors on form groups  -  by @logaretm (e873e)

   💣 Breaking Changes

  • Change form state isValid, isTouched, isDirty to be methods instead, these methods now accept a path to narrow down which path of the form to return the state for. by @genu #126
  • useForm's getErrors now return an array of strings rather than Issue collection objects by @genu #126
const { isTouched, setTouched, isDirty, isValid, getErrors, getError, setErrors } = useForm();

// Check if the form is touched
isTouched();

// Check if a field/path is touched
isTouched('field');
isTouched('address.city');

// Set the touched state of the form
setTouched(true);

// Set the touched state of a field/path
setTouched('field', true);
setTouched('address.city', true);

// Check if the form is dirty
isDirty();

// Check if a field/path is dirty
isDirty('field');
isDirty('address.city');

// Check if the form is valid
isValid();

// Check if a field/path is valid
isValid('field');
isValid('address.city');


// Get all the errors for the form
getErrors(); // string[]

// Get the errors for a field/path
getErrors('field'); // string[]
getErrors('address.city'); // string[]

// Set the errors for a field/path
setErrors('field', 'This is an error');
setErrors('address.city', 'This is another error');
setErrors('address.city', ['This is another error', 'This is another error 2']);

// Gets the first error for a field/path
getError('field'); // string
getError('address.city'); // string

   🐞 Bug Fixes

    View changes on GitHub