kreta/Kreta.WebApi/Naplo/Kreta.Naplo.Domain/V3/Utility/ValidationAttributes/ShortDateTimeAttribute.cs
2024-03-13 00:33:46 +01:00

16 lines
518 B
C#

using System;
using System.ComponentModel.DataAnnotations;
namespace Kreta.Naplo.Domain.V3.Utility.ValidationAttributes
{
[AttributeUsage(AttributeTargets.Property)]
internal sealed class ShortDateTimeAttribute : ValidationAttribute
{
public override bool IsValid(object value)
{
DateTime? timePropertyValue = value as DateTime?;
return !timePropertyValue.HasValue || timePropertyValue.Value - timePropertyValue.Value.Date == new TimeSpan(0);
}
}
}