Coder Social home page Coder Social logo

phougatv / fluentvalidation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fluentvalidation/fluentvalidation

0.0 0.0 0.0 19.34 MB

A popular .NET validation library for building strongly-typed validation rules.

Home Page: https://fluentvalidation.net

License: Apache License 2.0

Shell 0.01% C# 99.86% PowerShell 0.13% Batchfile 0.01%

fluentvalidation's Introduction

FluentValidation

Build Status NuGet Nuget

Full Documentation

A validation library for .NET that uses a fluent interface and lambda expressions for building strongly-typed validation rules.


Supporting the project

If you use FluentValidation in a commercial project, please sponsor the project financially. FluentValidation is developed and supported by @JeremySkinner for free in his spare time and financial sponsorship helps keep the project going. You can sponsor the project via either GitHub sponsors or OpenCollective.


Get Started

FluentValidation can be installed using the Nuget package manager or the dotnet CLI.

dotnet add package FluentValidation

Review our documentation for instructions on how to use the package.


Example

using FluentValidation;

public class CustomerValidator: AbstractValidator<Customer> {
  public CustomerValidator() {
    RuleFor(x => x.Surname).NotEmpty();
    RuleFor(x => x.Forename).NotEmpty().WithMessage("Please specify a first name");
    RuleFor(x => x.Discount).NotEqual(0).When(x => x.HasDiscount);
    RuleFor(x => x.Address).Length(20, 250);
    RuleFor(x => x.Postcode).Must(BeAValidPostcode).WithMessage("Please specify a valid postcode");
  }

  private bool BeAValidPostcode(string postcode) {
    // custom postcode validating logic goes here
  }
}

var customer = new Customer();
var validator = new CustomerValidator();

// Execute the validator
ValidationResult results = validator.Validate(customer);

// Inspect any validation failures.
bool success = results.IsValid;
List<ValidationFailure> failures = results.Errors;

License, Copyright etc

FluentValidation has adopted the Code of Conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information see the .NET Foundation Code of Conduct.

FluentValidation is copyright © 2008-2022 .NET Foundation, Jeremy Skinner and other contributors and is licensed under the Apache2 license.

Sponsors

This project is sponsored by the following organisations whose support help keep this project going:

This project is part of the .NET Foundation.

fluentvalidation's People

Contributors

jeremyskinner avatar jeremymeng avatar maksimkim avatar mattleibow avatar ademcatamak avatar utsxumiao avatar abatishchev avatar arphox avatar dmorganb avatar wizofaus avatar nsarris avatar purekrome avatar chris-za avatar matteobaglini avatar simoncropp avatar seankilleen avatar janv8000 avatar filipkristo avatar ddyakov avatar batzen avatar mourisso avatar medvedbeast avatar leehom0123 avatar avrahamcool avatar vetranio avatar robert-mccausland avatar richardlawley avatar nurulhudaapon avatar mrvitaly avatar gralin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.