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: enhance create role form with validation and error handling #1360

Conversation

JoshuaAkpan
Copy link
Contributor

Description

**Closes #1084 **

Changes proposed

What were you told to do?

Enhance the Create Role form to show clear and immediate error messages if any input field is empty or incorrect

What did you do?

  1. Updated the roleSchema to include validation for the name and description fields:

    • Added min and max length requirements
    • Added regex patterns to validate allowed characters
    • Updated error messages
  2. Changed the mode option in useForm to "onChange".

  3. Modified the input and textarea elements to show a red border when there's an error:

    • Added conditional classes based on the presence of errors
  4. Added error message display below each input field

Check List (Check all the applicable boxes)

🚨Please review the contribution guideline for this repository.

  • My code follows the code style of this project.
  • This PR does not contain plagiarized content.
  • The title and description of the PR is clear and explains the approach.
  • I am making a pull request against the dev branch (left side).
  • My commit messages styles matches our requested structure.
  • My code additions will fail neither code linting checks nor unit test.
  • I am only making changes to files I was requested to.

Screenshots/Videos

Error Message Display 1
roles-p-Error

Error Message Display 2
roles-p-Error2

Error Message Display 3
roles-p-Error3

Copy link
Contributor

github-actions bot commented Aug 24, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 14.67% 784 / 5343
🔵 Statements 14.35% 786 / 5475
🔵 Functions 14.15% 215 / 1519
🔵 Branches 9.82% 227 / 2311
File CoverageNo changed files found.
Generated in workflow #433

Copy link
Contributor

@billmal071 billmal071 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@incredible-phoenix246 incredible-phoenix246 merged commit 0b691a0 into hngprojects:dev Aug 24, 2024
3 checks passed
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.

[Enhancement]: No error message appears when an incorrect/empty input is entered in the "Create Role" form.
3 participants