burdier / ChainOfResponsibilityValidator

Chain Of Responsibility Validator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chain Of Responsibility Validator

.NET Core

Chain of Responsibility in C# Chain of Responsibility is behavioral design pattern that allows passing request along the chain of potential handlers until one of them handles request. The pattern allows multiple objects to handle the request without coupling sender class to the concrete classes of the receivers

#Example

 public class NameNotEmptyValidator : ValidatorBase {

        public override ErrorResult HandleValidation (User model, ErrorResult errorResult) {
            if (string.IsNullOrWhiteSpace (model.Name)) {
                errorResult.ErrorMessage.Add ("name", "name can't be null");
            }

            if (Successor != null) {
                return Successor.HandleValidation (model, errorResult);
            }

            return errorResult;

        }
    }

About

Chain Of Responsibility Validator


Languages

Language:C# 99.4%Language:Shell 0.6%