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

Add validation for adding a new Job #5

Open
3 tasks
sero-dev opened this issue Mar 7, 2021 · 4 comments
Open
3 tasks

Add validation for adding a new Job #5

sero-dev opened this issue Mar 7, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@sero-dev
Copy link
Owner

sero-dev commented Mar 7, 2021

Add validation for adding a new Job to the database. Validate whether the request object is valid.

A job can be saved in the database if it fulfills the following criteria:

  • Job Title is not empty
  • Employer is not empty
  • City is not empty
  • State is not empty and a valid US State
  • Status is not empty and is one of the following:
    • Applied
    • Rejected
    • Declined
    • Accepted
    • Offered
    • Code Challenge
    • Interview
    • Messed Up
    • Phone Call
    • Under Review
  • Amenities is not null

If DateSubmitted is null, the date will be set to Now.
If DateUpdated is null, the date will be set to DateSubmitted.

  • Learn how to use FluentValidation
  • Add Validation to Command/Query classes as a pre-action
  • Create unit tests for testing validation rules
@sero-dev sero-dev self-assigned this Mar 7, 2021
@sero-dev sero-dev added good first issue Good for newcomers enhancement New feature or request labels Mar 7, 2021
@sero-dev sero-dev removed their assignment Mar 7, 2021
@sero-dev sero-dev changed the title Add validation for adding a new Job. Add validation for adding a new Job Mar 7, 2021
@b13peterson
Copy link

I have experience with FluentValidation and can take care of this in the next few days

@sero-dev
Copy link
Owner Author

Just a heads up, in case my changes go before yours. I'll be changing to MongoDB (which shouldn't affect you at all) and I ended up moving the models in the Domain layer outside of the Entities folder (which would give you namespace conflicts, which will most likely be easy to resolve).

@b13peterson
Copy link

Currently the DateSubmitted and DateUpdated properties of Job are not nullable. My initial thought is to change their type to 'DateTime?', but let me know if you'd prefer that I validate against the default DateTime value.

Would you like me to create a pull request to the develop branch or would you prefer to create a new validation-addition branch? I don't seem to have access to create a branch, but I'm new to GitHub so I may be missing something.

@sero-dev
Copy link
Owner Author

There's a DTO for creating a job.
https://github.com/sero-dev/JobHunt/blob/master/Source/Application/DTOs/CreateJobRequest.cs

We should be validating the DTO, Having those fields null are valid because after validation and during the mapping process, null dates will be set to today. This is the mapping that does that:
https://github.com/sero-dev/JobHunt/blob/master/Source/Application/Mappings/JobProfile.cs

Originally, I had added that

If DateSubmitted is null, the date will be set to Now.
If DateUpdated is null, the date will be set to DateSubmitted.

This has already been done when using AutoMapper. I forgot to update the issue.

There is no develop branch anymore. You will need to fork the repository, make a branch off of master and commit your changes on that branch, then make a Pull Request into this repository. There are GitHub Actions that will build and test your incoming changes to ensure the rest of the application is working as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants