using Ardalis.GuardClauses;
public static void Main()
var employee = new Employee("Joe", "Smith", DateTime.Now, 10);
Console.WriteLine(employee.DateOfBirth);
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public decimal Salary { get; set; }
public DateTime DateOfBirth { get; set; }
#pragma warning disable CS8618
public Employee(string firstName, string lastName, DateTime dateOfBirth, decimal salary)
FirstName = Guard.Against.NullOrWhiteSpace(nameof(firstName), firstName);
LastName = Guard.Against.NullOrWhiteSpace(nameof(lastName), lastName);
Salary = Guard.Against.NegativeOrZero(salary, nameof(salary));
DateOfBirth = Guard.Against.AgainstExpression(date => date.Date > DateTime.Now.Date , dateOfBirth, "test");