Skip to content

IP Address - Validation #692

@ghost

Description

Good day,

I was hoping someone can kindly help me with this issue, how would correctly validate an IP Address using FluentValidation.

Does FluentValidation have such functionality?

public abstract class GatewayValidation<T> : AbstractValidator<T> where T : GatewayCommand
    {
        protected void ValidateName()
        {
            RuleFor(g => g.Name)
                .NotEmpty().WithMessage("Please ensure you have entered the Name")
                .Length(2, 16).WithMessage("The Name must have between 2 and 16 characters");
        }

        protected void ValidateIPAddress()
        {
            RuleFor(g => g.IPAddress)
                .NotEmpty().WithMessage("IP address format is invalid");
        }

        protected void ValidateId()
        {
            RuleFor(g => g.Id)
                .NotEqual(Guid.Empty);
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions