This commit is contained in:
2025-02-13 09:05:34 +04:00
parent bca5c116a0
commit 5a5fc38cb6
5 changed files with 2 additions and 18 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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");

View File

@@ -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()})");
}

View File

@@ -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;