Skip to content

Latest commit

 

History

History
64 lines (49 loc) · 1.92 KB

File metadata and controls

64 lines (49 loc) · 1.92 KB

Hackney.Core.Enums

This package provides enums for use by clients. These include:

  • TargetType

This package also provides ready-made validators for these enums. These include:

TargetTypeValidator

The TargetTypeValidator uses Fluent Validation PropertyValidator implementation that will check if a provided enum is a valid TargeType.

Usage

Applications using this validator will need to have already configured their application to use Fluent Validation. The validator is used through the RuleBuilder extension method IsTargetType() that can be used when defining a validation rule.

using FluentValidation;
using Hackney.Core.Enums;

namespace SomeApi.Domain.Validation
{
    public class SomeRequestObjectValidator : AbstractValidator<SomeRequestObject>
    {
        public SomeRequestObjectValidator()
        {
            // TargetType is an enum
            RuleFor(x => x.TargetType).IsTargetType();
        }
    }
}

TargetTypeNameValidator

The TargetTypeNameValidator uses Fluent Validation PropertyValidator implementation that will check if a provided string is a valid TargeType.

Usage

Applications using this validator will need to have already configured their application to use Fluent Validation. The validator is used through the RuleBuilder extension method IsTargetType() that can be used when defining a validation rule.

using FluentValidation;
using Hackney.Core.Enums;

namespace SomeApi.Domain.Validation
{
    public class SomeRequestObjectValidator : AbstractValidator<SomeRequestObject>
    {
        public SomeRequestObjectValidator()
        {
            // TargetType is a string
            RuleFor(x => x.TargetType).IsTargetType();
        }
    }
}