all done
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class RequestDataModel(string id, string workerId, string email, double s
|
||||
throw new ValidationException("The value in the field WorkerId is not a unique identifier");
|
||||
if (Email.IsEmpty())
|
||||
throw new ValidationException("Worker Email is empty");
|
||||
if (!Regex.IsMatch(Email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$"))
|
||||
if (!Regex.IsMatch(Email, @"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"))
|
||||
throw new ValidationException("Field Email is not a email");
|
||||
if (Sum <= 0)
|
||||
throw new ValidationException("Field Sum is less than or equal to 0");
|
||||
|
||||
@@ -29,7 +29,7 @@ birthDate, DateTime employmentDate, bool isDeleted) : IValidation
|
||||
throw new ValidationException($"Minors cannot be hired (BirthDate = { BirthDate.ToShortDateString() })");
|
||||
if (EmploymentDate.Date < BirthDate.Date)
|
||||
throw new ValidationException("The date of employment cannot be less than the date of birth");
|
||||
if ((EmploymentDate - BirthDate).TotalDays / 365 < 16) // EmploymentDate.Year - BirthDate.Year
|
||||
if ((EmploymentDate - BirthDate).TotalDays / 365 < 16)
|
||||
throw new ValidationException($"Minors cannot be hired (EmploymentDate - { EmploymentDate.ToShortDateString() }, BirthDate - { BirthDate.ToShortDateString()})");
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareTests.DataModelsTests;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user