Search Results for

    Show / Hide Table of Contents

    Class DatabaseClassValidation

    Allows you to create class level validation, instead of individual field level, that runs when directly connected to the database only

    Inheritance
    System.Object
    System.Attribute
    System.ComponentModel.DataAnnotations.ValidationAttribute
    DatabaseValidation
    DatabaseClassValidation
    Inherited Members
    DatabaseValidation.RequiresValidationContext
    DatabaseValidation.IsValid(Object, ValidationContext)
    System.ComponentModel.DataAnnotations.ValidationAttribute.FormatErrorMessage(System.String)
    System.ComponentModel.DataAnnotations.ValidationAttribute.GetValidationResult(System.Object, System.ComponentModel.DataAnnotations.ValidationContext)
    System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(System.Object)
    System.ComponentModel.DataAnnotations.ValidationAttribute.Validate(System.Object, System.ComponentModel.DataAnnotations.ValidationContext)
    System.ComponentModel.DataAnnotations.ValidationAttribute.Validate(System.Object, System.String)
    System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessage
    System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessageResourceName
    System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessageResourceType
    System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessageString
    System.Attribute.Equals(System.Object)
    System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type)
    System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type, System.Boolean)
    System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type)
    System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type, System.Boolean)
    System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type)
    System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type, System.Boolean)
    System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type)
    System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.Assembly)
    System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type)
    System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo)
    System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type)
    System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.Module)
    System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type)
    System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo)
    System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type)
    System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type, System.Boolean)
    System.Attribute.GetHashCode()
    System.Attribute.IsDefaultAttribute()
    System.Attribute.IsDefined(System.Reflection.Assembly, System.Type)
    System.Attribute.IsDefined(System.Reflection.Assembly, System.Type, System.Boolean)
    System.Attribute.IsDefined(System.Reflection.MemberInfo, System.Type)
    System.Attribute.IsDefined(System.Reflection.MemberInfo, System.Type, System.Boolean)
    System.Attribute.IsDefined(System.Reflection.Module, System.Type)
    System.Attribute.IsDefined(System.Reflection.Module, System.Type, System.Boolean)
    System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type)
    System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type, System.Boolean)
    System.Attribute.Match(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: LemonEdge.API.Attributes.Validation
    Assembly: API.dll
    Syntax
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = true)]
    public class DatabaseClassValidation : DatabaseValidation
    Remarks

    You can mark this attribute against a class, referring to a custom validation like so:

    public interface IMyClass { }
    
    [DatabaseClassValidation(typeof(MyCustomValidation), nameof(MyCustomValidation.test))]
    public class MyClass : IMyClass
    {
    
    }
    
    public static class MyCustomValidation
    {
        public static Task<ValidationResult> ValidateMyClass(IMyClass item, LemonEdge.Core.IEntityUpdater dbCon, LemonEdge.Entities.IReadOnlyCache cache, LemonEdge.API.Core.UserInfo user, ValidationContext validationContext)
        {
            //Custom checks here
            return Task.FromResult(ValidationResult.Success);
        }
    }

    Constructors

    DatabaseClassValidation(Type, String)

    Creates a new DatabaseClass vaidation attribute that specifies a static method on the specified class to use to validate this class

    Declaration
    public DatabaseClassValidation(Type validationClass, string classFunctionName)
    Parameters
    Type Name Description
    System.Type validationClass

    The class that holds the method used for validatin this class

    System.String classFunctionName

    The static method name of signature static System.Threading.Tasks.Task<TResult> IsValid(T value, IEntityUpdater dbCon, IReadOnlyCache cache, UserInfo user, ValidationContext validationContext)

    Properties

    TypeId

    Have to override this if AllowMultiple is true

    Declaration
    public override object TypeId { get; }
    Property Value
    Type Description
    System.Object
    Overrides
    System.Attribute.TypeId

    Methods

    IsValid(Object, IEntityUpdater, IReadOnlyCache, UserInfo, ValidationContext)

    Declaration
    protected override Task<ValidationResult> IsValid(object value, IEntityUpdater dbCon, IReadOnlyCache cache, UserInfo user, ValidationContext validationContext)
    Parameters
    Type Name Description
    System.Object value
    IEntityUpdater dbCon
    IReadOnlyCache cache
    UserInfo user
    System.ComponentModel.DataAnnotations.ValidationContext validationContext
    Returns
    Type Description
    System.Threading.Tasks.Task<System.ComponentModel.DataAnnotations.ValidationResult>
    Overrides
    DatabaseValidation.IsValid(Object, IEntityUpdater, IReadOnlyCache, UserInfo, ValidationContext)

    Extension Methods

    MiscExtensions.SetIfNotEqual<T, P>(T, Expression<Func<T, P>>, P)
    ReflectionExtensions.ClearEventInvocations(Object, String)
    StringExtensions.ToCSVFormatString(Object, Type)
    SQLExtensions.ToSQLValue(Object, Boolean)

    See Also

    DatabaseValidation
    In This Article
    Back to top © LemonTree Software Ltd. All rights reserved.