Created all validators
This commit is contained in:
49
.idea/.idea.BookHive/.idea/workspace.xml
generated
49
.idea/.idea.BookHive/.idea/workspace.xml
generated
@@ -6,23 +6,25 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="4c0ad985-5b6e-4587-85a5-1b48273bdb1d" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Authors/CreateAuthorDtoValidator.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Authors/GetAuthorDtoValidator.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Authors/UpdateAuthorDtoValidator.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Books/CreateBookDtoValidator.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Books/GetBookDtoValidator.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Books/UpdateBookDtoValidator.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/CustomValidators.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Loans/CreateLoanDtoValidator.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Loans/PatchLoanDtoValidator.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Loans/UpdateLoanDtoValidator.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Members/CreateMemberDtoValidator.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Members/UpdateMemberDtoValidator.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Reviews/CreateReviewDtoValidator.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/BookHive/Validators/Reviews/UpdateReviewDtoValidator.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.BookHive/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.BookHive/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/DTO/Book/GetBookDto.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/DTO/Book/GetBookDto.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/MappingProfiles/EntityToDtoMappings.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/MappingProfiles/EntityToDtoMappings.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/Program.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/Specifications/Books/GetBookByIdSpec.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/Specifications/Books/GetBookByIdSpec.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/Validators/Books/CreateBookDtoValidator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/Validators/Books/CreateBookDtoValidator.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/Validators/Loans/CreateLoanDtoValidator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/Validators/Loans/CreateLoanDtoValidator.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/Validators/Reviews/CreateReviewDtoValidator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/Validators/Reviews/CreateReviewDtoValidator.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/Validators/Reviews/UpdateReviewDtoValidator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/Validators/Reviews/UpdateReviewDtoValidator.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/bin/Debug/net10.0/BookHive.dll" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/bin/Debug/net10.0/BookHive.dll" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/bin/Debug/net10.0/BookHive.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/bin/Debug/net10.0/BookHive.pdb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfo.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfo.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfoInputs.cache" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfoInputs.cache" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.csproj.CoreCompileInputs.cache" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.csproj.CoreCompileInputs.cache" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.dll" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.dll" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.pdb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/ref/BookHive.dll" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/ref/BookHive.dll" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/refint/BookHive.dll" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/refint/BookHive.dll" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/rjsmcshtml.dswa.cache.json" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/rjsmcshtml.dswa.cache.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/rjsmrazor.dswa.cache.json" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/rjsmrazor.dswa.cache.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/rider.project.restore.info" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/rider.project.restore.info" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -130,7 +132,7 @@
|
||||
<updated>1773087844958</updated>
|
||||
<workItem from="1773087846465" duration="527000" />
|
||||
<workItem from="1773088517368" duration="6491000" />
|
||||
<workItem from="1773126764051" duration="5972000" />
|
||||
<workItem from="1773126764051" duration="8401000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="first commit">
|
||||
<option name="closed" value="true" />
|
||||
@@ -172,7 +174,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1773128141686</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="6" />
|
||||
<task id="LOCAL-00006" summary="added validators in project">
|
||||
<option name="closed" value="true" />
|
||||
<created>1773132752060</created>
|
||||
<option name="number" value="00006" />
|
||||
<option name="presentableId" value="LOCAL-00006" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1773132752060</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="7" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -186,7 +196,8 @@
|
||||
<MESSAGE value="created all endpoints" />
|
||||
<MESSAGE value="fix error with sending responses" />
|
||||
<MESSAGE value="insert datas" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="insert datas" />
|
||||
<MESSAGE value="added validators in project" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="added validators in project" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
|
||||
@@ -63,7 +63,4 @@ app.UseAuthentication()
|
||||
|
||||
// app.UseCors();
|
||||
|
||||
app.Services.GetRequiredService<BookHiveDbContext>().Database.EnsureDeleted();
|
||||
app.Services.GetRequiredService<BookHiveDbContext>().Database.EnsureCreated();
|
||||
|
||||
app.Run();
|
||||
@@ -8,6 +8,7 @@ public class GetBookByIdSpec : SingleResultSpecification<Book>
|
||||
public GetBookByIdSpec(int bookId)
|
||||
{
|
||||
Query
|
||||
.Include(x => x.Author)
|
||||
.Where(x => x.Id == bookId);
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,9 @@ public class CreateBookDtoValidator : Validator<CreateBookDto>
|
||||
.WithMessage("Le titre ne peut pas dépasser 200 caractères.");
|
||||
|
||||
RuleFor(x => x.Isbn)
|
||||
.NotEmpty().WithMessage("L’ISBN est obligatoire.")
|
||||
.Matches(@"^\d{13}$")
|
||||
.WithMessage("L’ISBN doit contenir exactement 13 chiffres.");
|
||||
.NotEmpty()
|
||||
.WithMessage("L’ISBN est obligatoire.")!
|
||||
.IsValidIsbn13();
|
||||
|
||||
RuleFor(x => x.PageCount)
|
||||
.GreaterThan(0)
|
||||
|
||||
@@ -26,6 +26,17 @@ public class CreateLoanDtoValidator : Validator<CreateLoanDto>
|
||||
.GreaterThan(d => d.LoanDate)
|
||||
.WithMessage("Due date must be in the future.")
|
||||
.Must((loan, dueDate) => dueDate <= loan.LoanDate.AddDays(30))
|
||||
.WithMessage("Due date must be in the future.");;
|
||||
.WithMessage("Due date must be in the future.");
|
||||
|
||||
RuleFor(x => x.DueDate)
|
||||
.Must((dto, dueDate) =>
|
||||
{
|
||||
var dayOfWeek = dto.LoanDate.DayOfWeek;
|
||||
var isWeekend = dayOfWeek == DayOfWeek.Saturday
|
||||
|| dayOfWeek == DayOfWeek.Sunday;
|
||||
var maxDays = isWeekend ? 14 : 30;
|
||||
return dueDate <= dto.LoanDate.AddDays(maxDays);
|
||||
})
|
||||
.WithMessage("La durée max est de 14j (week-end) ou 30j (semaine).");
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class CreateReviewDtoValidator : Validator<CreateReviewDto>
|
||||
|
||||
RuleFor(x => x.Rating)
|
||||
.InclusiveBetween(1, 5)
|
||||
.WithMessage("Rating must be between 1 and 5.");
|
||||
.WithMessage(x => $"La note {x.Rating} est invalide. Elle doit être comprise entre 1 et 5.");
|
||||
|
||||
When(x => x.Comment is not null, () =>
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ public class UpdateReviewDtoValidator : Validator<UpdateReviewDto>
|
||||
|
||||
RuleFor(x => x.Rating)
|
||||
.InclusiveBetween(1, 5)
|
||||
.WithMessage("Rating must be between 1 and 5.");
|
||||
.WithMessage(x => $"La note {x.Rating} est invalide. Elle doit être comprise entre 1 et 5.");
|
||||
|
||||
When(x => x.Comment is not null, () =>
|
||||
{
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("BookHive")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ecdabab5a1a621c003643d8f0f2e492d314951f9")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9f858df5f8559ef4eece66d288194275a0509245")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("BookHive")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("BookHive")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
38e3040d9641db39778141a07f9c125f563b85c555e95be9b8385c95c14acd96
|
||||
24c20bc00ebed273ed8d88d70e9db8fba99e16f4c11f44fa290911d9e2a0ca7d
|
||||
|
||||
@@ -1 +1 @@
|
||||
41fc3b734d4bc6835927453b9f4d7cdd11e742d0714a8d542d23004e43ece95a
|
||||
83126e6bfb83bdfd52cfec65d256c75a3ab035c366b329c9b517e33f5e1849d1
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
{"GlobalPropertiesHash":"GuRprL5mC7hc0CG8FgEPpIWKx/Dfl1Jhxvhk8sWxBEQ=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["kIO\u002BgVQX72rEP/AM8N4erO8boVd0NQ5bkxTtUbSKS9I=","Uf8MX/\u002BVloY39fAvymRXdZ4qt/FRES4KRvClr57fYDU=","lfZuIjVBvtBmrqX0WvkpZ3DYOYwGL3QDuIUtKarpEII=","cKn2pHge4p72bHZX6RcPkCSMotE3yKol468IJfCIBSs=","ns1MuHuvJ97vk/1G9RavyVW40bQqScr\u002BntDnZSwZUHA="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
{"GlobalPropertiesHash":"GuRprL5mC7hc0CG8FgEPpIWKx/Dfl1Jhxvhk8sWxBEQ=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["kIO\u002BgVQX72rEP/AM8N4erO8boVd0NQ5bkxTtUbSKS9I=","Uf8MX/\u002BVloY39fAvymRXdZ4qt/FRES4KRvClr57fYDU=","lfZuIjVBvtBmrqX0WvkpZ3DYOYwGL3QDuIUtKarpEII=","cKn2pHge4p72bHZX6RcPkCSMotE3yKol468IJfCIBSs=","YDM8gir9t/JobnY2IBraj9MVLPnhuLmU9uuLWanHPfo="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
@@ -1 +1 @@
|
||||
{"GlobalPropertiesHash":"03RR8FZ+u5Ay9wTZirfGS5vS3BFumeGaLKPk0IyeRqs=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["kIO\u002BgVQX72rEP/AM8N4erO8boVd0NQ5bkxTtUbSKS9I=","Uf8MX/\u002BVloY39fAvymRXdZ4qt/FRES4KRvClr57fYDU=","lfZuIjVBvtBmrqX0WvkpZ3DYOYwGL3QDuIUtKarpEII=","cKn2pHge4p72bHZX6RcPkCSMotE3yKol468IJfCIBSs=","ns1MuHuvJ97vk/1G9RavyVW40bQqScr\u002BntDnZSwZUHA="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
{"GlobalPropertiesHash":"03RR8FZ+u5Ay9wTZirfGS5vS3BFumeGaLKPk0IyeRqs=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["kIO\u002BgVQX72rEP/AM8N4erO8boVd0NQ5bkxTtUbSKS9I=","Uf8MX/\u002BVloY39fAvymRXdZ4qt/FRES4KRvClr57fYDU=","lfZuIjVBvtBmrqX0WvkpZ3DYOYwGL3QDuIUtKarpEII=","cKn2pHge4p72bHZX6RcPkCSMotE3yKol468IJfCIBSs=","YDM8gir9t/JobnY2IBraj9MVLPnhuLmU9uuLWanHPfo="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
@@ -1 +1 @@
|
||||
17731267691332367
|
||||
17731341506250102
|
||||
Reference in New Issue
Block a user