summaryrefslogtreecommitdiff
path: root/Models
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2022-09-20 20:22:18 -0500
committerHombreLaser <sebastian-440@live.com>2022-09-20 20:22:18 -0500
commitf4f9762085b9858eacd7906188841e06e20a893a (patch)
treeb5dc1d74628f06e305afc453c4676e29359f1ba8 /Models
parent766d9635dc09886707213cdbafa8a783a143ce84 (diff)
Añadidos validadores
Diffstat (limited to 'Models')
-rw-r--r--Models/Author.cs7
-rw-r--r--Models/Book.cs10
2 files changed, 17 insertions, 0 deletions
diff --git a/Models/Author.cs b/Models/Author.cs
index 9f04a58..23e8a64 100644
--- a/Models/Author.cs
+++ b/Models/Author.cs
@@ -1,10 +1,17 @@
+using System.ComponentModel.DataAnnotations;
+
namespace LibraryAPI.Models {
public class Author {
public long Id { get; set; }
public List<Book>? Books { get; set; }
+ [Required]
public string? Country { get; set; }
+ [Required]
+ [StringLength(64, ErrorMessage = "Name too long")]
public string? Name { get; set; }
+ [Required]
public int YearOfBirth { get; set; }
+ [Required]
public string[]? languages { get; set; }
}
} \ No newline at end of file
diff --git a/Models/Book.cs b/Models/Book.cs
index 29faa97..49bd527 100644
--- a/Models/Book.cs
+++ b/Models/Book.cs
@@ -1,12 +1,22 @@
+using System.ComponentModel.DataAnnotations;
+using LibraryAPI.Validators;
+
namespace LibraryAPI.Models {
public class Book {
public long Id { get; set; }
+ [Required]
public long AuthorId { get; set; }
public Author? Author { get; set; }
+ [Required]
public int PublicationYear { get; set; }
+ [Required]
public string[]? Genres { get; set; }
public int Edition { get; set; }
+ [Required]
+ [ISBN(13)]
public string? ISBN { get; set; }
+ [Required]
+ [StringLength(128, ErrorMessage = "Title too long")]
public string? Title { get; set; }
}
} \ No newline at end of file