Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (22 sloc) 783 Bytes
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NHail.ComponentModel.DataAnnotations.Fluent
{
public class ValidatableObjectAttribute : ValidationAttribute
{
private readonly Func<object, ValidationContext, ValidationResult> _isValid;
public ValidatableObjectAttribute(Func<object, ValidationContext, ValidationResult> isValid)
{
_isValid = isValid;
}
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
return _isValid(value, validationContext);
}
public override bool RequiresValidationContext => true;
}
}