Working on users view, added infrastructure lib

This commit is contained in:
2020-08-18 21:59:10 +02:00
parent 697886730e
commit 8fcd1c4c44
28 changed files with 184 additions and 99 deletions

View File

@ -0,0 +1,22 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using UserService.Infrastructure.DataModels;
namespace UserService.Infrastructure
{
public static class Validators
{
public static bool? ValidateEmail(string mailAddress)
{
if (string.IsNullOrEmpty(mailAddress)) return null;
return new EmailAddressAttribute().IsValid(mailAddress);
}
public static bool? ValidateCommonName(string commonName, IReadOnlyList<User> users)
{
if (string.IsNullOrEmpty(commonName)) return false;
return users.All(x => x.CommonName != commonName);
}
}
}