mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11:11:10 +00:00
Implements complete validation rules for adding a book.
This commit is contained in:
1 parent
0eb7b453f6
commit
ed0d341513
8 files changed
+254
-78
No files matched your search
+1
-1
@@ -51,7 +51,7 @@ public class BookRating : Rating
|
||||
public static ErrorOr<BookRating> Create(decimal value, decimal maxValue, Optional<BookRatingSource> source, Optional<int> voteCount)
|
||||
{
|
||||
if (maxValue < 0 || value < 0)
|
||||
return Errors.Metadata.RatingMustBePositive;
|
||||
return Errors.Metadata.RatingValueMustBePositive;
|
||||
if (value > maxValue)
|
||||
return Errors.Metadata.RatingValueCannotBeGreaterThanMaxValue;
|
||||
return new BookRating(value, maxValue, source, voteCount);
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public sealed class Isbn : ValueObject
|
||||
{
|
||||
// enforce invariants
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return Errors.WrittenContent.IsbnCannotBeEmpty;
|
||||
return Errors.WrittenContent.IsbnValueCannotBeEmpty;
|
||||
// remove hyphens and spaces, for validation
|
||||
string cleanedValue = Regex.Replace(value, @"[-\s]", string.Empty);
|
||||
switch (format)
|
||||
|
||||
Reference in new issue
Block a user