Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add setErrors and setFieldError #24

Merged
merged 5 commits into from
Jun 16, 2023
Merged

Conversation

Mini-ghost
Copy link
Owner

@Mini-ghost Mini-ghost commented May 27, 2023

πŸ”— Linked issue

Resolves #17

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

  • Add setErrors and setFieldError

    Currently, in Vorms, it is not possible to set errors without performing validation. This limitation becomes inconvenient when we encounter errors in API responses that do not adhere to the predefined validation rules.

    To address this issue, we have introduced two new methods, setError and setFieldError, in this PR. These methods can be used within the handleSubmit function to provide error feedback to the user after performing asynchronous validation. (ex: API response validation errors occur).

  • More flexible error message type

    According to Can Vorms provide pass/fail results for each validation specification?Β #17, there are cases where we need to provide a list of error messages for a field, displaying all the reasons for failure to the user, instead of just a single error message string.

    In the current version, we can still use an array of strings to return a list of error messages, and it works, but dealing with type errors can be frustrating.

    With this PR, we introduce a solution that allows us to return an error message, which can be either a string or an array of strings, without encountering type errors. This improvement ensures a smoother experience by providing flexibility in handling error messages, accommodating both single and multiple failure reasons.

πŸ“ Checklist

  • I have read the Contributing Guidelines.
  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@Mini-ghost Mini-ghost merged commit f5bb500 into main Jun 16, 2023
3 checks passed
@Mini-ghost Mini-ghost mentioned this pull request Jun 23, 2023
8 tasks
@Mini-ghost Mini-ghost deleted the feature/set-error branch June 23, 2023 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can Vorms provide pass/fail results for each validation specification?
1 participant