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

fix-#77:Refactor Form Validation with react-hook-form & zod #254

Closed
wants to merge 10 commits into from
Closed

fix-#77:Refactor Form Validation with react-hook-form & zod #254

wants to merge 10 commits into from

Conversation

ShristiSharan
Copy link

Summary

This PR address
1.Validation schema modification
2.Form validation logic enhancement
3. Image selection Improvements

Description

Added react hook form and zod which helps in validating the input fields and to show the error as user fills the required input field rather than showing error after complete submission.
The validation schema has been updated to include checks for the author's name length and the maximum number of selected categories, image selection, blog title length and description of blog to be posted.

Users now have the option to select an image for their blog post either by providing a URL or uploading a file from their device. Additionally, feedback is provided to the user upon image selection.

Images

Helping user to fill the input as per requirement beforehand:

val error

and once corrected, error gets removed-

VAL ERROR REES

Issue(s) Addressed

Closes #77

Prerequisites

Copy link

vercel bot commented May 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wanderlust ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 18, 2024 2:32pm
wanderlust-backend ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 18, 2024 2:32pm

@krishnaacharyaa
Copy link
Owner

Thank you @ShristiSharan
#250 We need this to go in for us to get this in.
After this goes in,
Kindly rebase this branch and then we'll test it properly

@krishnaacharyaa
Copy link
Owner

@ShristiSharan please rebase the branch to latest main

@krishnaacharyaa
Copy link
Owner

We still have conflicts @ShristiSharan, can you kindly handle this

@ShristiSharan
Copy link
Author

We still have conflicts @ShristiSharan, can you kindly handle this

I have rebased issue#77 branch from which i raised the PR to refactor-branch(the latest updated one) but no changes or conflicts seems to be resolved here. some help needed to look into it.

@krishnaacharyaa
Copy link
Owner

Okay when you rebase you have to make sure while resolving 2 files as there are the things giving you problem.

  1. frontend/src/pages/add-blog.tsx
    Your changes and https://github.com/krishnaacharyaa/wanderlust/pull/250/files#diff-246536cf660d1ef43d8fd88eadcea213f3410b6a18a0cc4d0563460c55ecd844 changes are both in

  2. frontend/package-lock.json
    You can accept the remote wala, that is "their" code when it comes in the vs code to resolve the conflicts of this file

@krishnaacharyaa
Copy link
Owner

End goal is the latest things should come and sit in your issue#77 branch.

ig it is not directly possible, for that you have to first rebase your local forked main branch with the upstream main
And then from your updated main get it into your issue#77 branch...

Try it, we'll figure out later if you feel too challenging, because it is challenging @ShristiSharan xD

Happy learning :)

@ShristiSharan
Copy link
Author

End goal is the latest things should come and sit in your issue#77 branch.

ig it is not directly possible, for that you have to first rebase your local forked main branch with the upstream main And then from your updated main get it into your issue#77 branch...

Try it, we'll figure out later if you feel too challenging, because it is challenging @ShristiSharan xD

Happy learning :)

Ohkay will try it out to resolve this git challenge(under guidance ) and if it feels too much then will follow the approach to meet the end goal eventually.

@krishnaacharyaa
Copy link
Owner

Figured out ? @ShristiSharan
Where you able to sync up with @0xmohitsen ?

@krishnaacharyaa
Copy link
Owner

@ShristiSharan please refer #83
And figure out everything about the error messages...
We want exact to almost similar to this ... You can be more innovative

@ShristiSharan
Copy link
Author

Figured out ? @ShristiSharan Where you able to sync up with @0xmohitsen ?

yup!...working on it

@ShristiSharan
Copy link
Author

@ShristiSharan please refer #83 And figure out everything about the error messages... We want exact to almost similar to this ... You can be more innovative

Ohk Sure, i'll look into #83 and discuss with you further as reference drawn

Copy link
Owner

@krishnaacharyaa krishnaacharyaa left a comment

Choose a reason for hiding this comment

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

Kindly run the npm run format and unstage the package.lock-json which is causing merge conflict and address the reviews

@@ -5,6 +5,8 @@ import CategoryPill from '@/components/category-pill';
import { createSlug } from '@/utils/slug-generator';
import { TestProps } from '@/types/test-props';



export default function FeaturedPostCard({
Copy link
Owner

Choose a reason for hiding this comment

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

Why these extra lines?


const addBlogSchema = z.object({
title: z.string().min(3, 'Title must be at least 3 characters long'),
description: z.string().min(10, 'Description must be at least 10 characters long'),
Copy link
Owner

Choose a reason for hiding this comment

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

Kindly update the validation as said in the comment

};

// const handleInputChange = (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
// const { name, value } = e.target;
Copy link
Owner

Choose a reason for hiding this comment

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

Kindly remove this comment

if (
!formData.title ||
Copy link
Owner

Choose a reason for hiding this comment

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

formData please, makes it more readable

@krishnaacharyaa
Copy link
Owner

Once the above is done, kindly update with a small video demonstrating the working of it @ShristiSharan

@krishnaacharyaa
Copy link
Owner

Kindly take care of the comments in the new PR

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.

Refactor Form vailidation using the react-hook-form and zod
2 participants