Show / Hide Table of Contents

Class Validation

Concrete class with interface implementation IValidation validation of the model.

Inheritance
System.Object
Validation
Implements
IValidation
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: StoneCo.Framework.Model.ModelRules
Assembly: cs.temp.dll.dll
Syntax
public class Validation : IValidation

Constructors

Validation(String, String)

Default constructor to set field name and message description.

Declaration
public Validation(string attribute, string message)
Parameters
Type Name Description
System.String attribute

The field name validated.

System.String message

The message that describes the field validation.

Examples

Foo class used in this example.

public class Foo : IModel
{
    public Foo(string code, string name)
    {
        Code = code;
        Name = name;
        Validate();
    }

    public string Code { get; private set; }
    public string Name { get; private set; }
    public IEnumerable<IValidation> Validations { get; private set; } = new List<IValidation>();

    public void Validate()
    {
        var validations = new List<IValidation>();

        if (string.IsNullOrWhiteSpace(Name)) 
            validations.Add(new Validation("Name", "The field is required!"));

        Validations = validations;
    }
}

Properties

Attribute

The field name validated.

Declaration
public string Attribute { get; }
Property Value
Type Description
System.String

String value with field name.

Message

The message that describes the field validation.

Declaration
public string Message { get; }
Property Value
Type Description
System.String

String value with message description.

Implements

IValidation
Back to top Generated by DocFX