Validation Framework
Search Results for

    Show / Hide Table of Contents

    Class ValidationRule<T>

    Represents a single validation rule with a condition and error message.

    Inheritance
    object
    ValidationRule<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: ValidationFramework
    Assembly: ValidationFramework.dll
    Syntax
    public class ValidationRule<T>
    Type Parameters
    Name Description
    T

    The type of value to validate.

    Constructors

    | Edit this page View Source

    ValidationRule(Func<T, bool>, string)

    Initializes a new instance of the ValidationRule<T> class.

    Declaration
    public ValidationRule(Func<T, bool> rule, string errorMessage)
    Parameters
    Type Name Description
    Func<T, bool> rule

    The function that defines the validation condition.

    string errorMessage

    The error message to return if validation fails.

    Methods

    | Edit this page View Source

    Validate(T)

    Validates the specified value against this rule.

    Declaration
    public (bool isValid, string error) Validate(T value)
    Parameters
    Type Name Description
    T value

    The value to validate.

    Returns
    Type Description
    (bool isValid, string error)

    A tuple containing the validation result and error message.

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX