PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 9, 2022

[FIXED] How to check the length of decimal types with fluent validation?

 August 09, 2022     asp.net, decimal, fluent, validation     No comments   

Issue

I want a decimal type variable to be greater than zero with fluent validation. How can I do this control with fluent validation?

  • Daily rental fee must be greater than zero

*** DailyPrice is decimal type

public class CarValidator : AbstractValidator<Car>
{
    public CarValidator()
    {
        RuleFor(p => p.Name).MinimumLength(2);
        RuleFor(p => p.DailyPrice).MinimumLength(2);
    }
}

Solution

Try this:

RuleFor(p => p.DailyRentalFee).GreaterThan(0);


Answered By - Arib Yousuf
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing