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

NW6 | Fikret Ellek | React-Module-Project | Week-4 | Feature Validate AddBooking #63

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

fikretellek
Copy link
Collaborator

@fikretellek fikretellek commented Mar 27, 2024

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

Copy link

netlify bot commented Mar 27, 2024

Deploy Preview for cyf-react-hotel-project ready!

Name Link
🔨 Latest commit f274f4d
🔍 Latest deploy log https://app.netlify.com/sites/cyf-react-hotel-project/deploys/66039310c3ecd0000893cea0
😎 Deploy Preview https://deploy-preview-63--cyf-react-hotel-project.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@fikretellek fikretellek linked an issue Mar 27, 2024 that may be closed by this pull request
return true;
}
};

const handleSubmit = (e) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Brilliant calling validateBooking function inside the handleSubmit function.

@fhkahin fhkahin merged commit 524e1b9 into main Apr 6, 2024
4 checks passed
Copy link
Collaborator

@Ara225 Ara225 left a comment

Choose a reason for hiding this comment

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

Looks good

if (!isNaN(parseInt(formData.firstName))) {
alert("Enter a valid name");
} else if (!isNaN(parseInt(formData.surname))) {
alert("Enter a valid surname");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is an intresting approach to the problem. I think it mostly works, even for special letters such as Ö which is good as few validation solutions do. Of course it includes ! and other special chars

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as you said regex would cover it all. to get a valid name should I use [a-zA-z]?

formData.email.includes(".") &&
formData.email.indexOf("@") === formData.email.lastIndexOf("@") &&
formData.email.indexOf("@") < formData.email.lastIndexOf(".")
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This works but it's fairly hard to read I normally use a regex in these cases but that is a diffrent thing. A fairly simple regex such as formData.email.match(/^.+@.+.$/)) should work

} else if (!(formData.roomId > 0 && formData.roomId < 100)) {
alert("Enter a valid roon id");
} else if (!(formData.checkInDate < formData.checkOutDate)) {
alert("Enter valid dates");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good work, a more specfic error message here would be helpful to the user though - doesn't say which date is invalid

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.

Feature Validate AddBooking
3 participants