Repository: andrebaltieri/flunt
Branch: main
Commit: 38f159b1fd48
Files: 64
Total size: 589.4 KB
Directory structure:
gitextract_dejsxxuh/
├── .github/
│ └── workflows/
│ └── main.yml
├── .gitignore
├── Flunt/
│ ├── Flunt.csproj
│ ├── Localization/
│ │ ├── FluntErrorMessages.cs
│ │ ├── FluntFormats.cs
│ │ └── FluntRegexPatterns.cs
│ ├── Notifications/
│ │ ├── INotifiable.cs
│ │ ├── Notifiable.cs
│ │ └── Notification.cs
│ └── Validations/
│ ├── BoolValidationContract.cs
│ ├── Contract.cs
│ ├── CreditCardValidation.cs
│ ├── DateTimeValidationContract.cs
│ ├── DecimalValidationContract.cs
│ ├── DocumentValitionContract.cs
│ ├── DoubleValidationContract.cs
│ ├── EmailValidationContract.cs
│ ├── FloatValidationContract.cs
│ ├── GuidValidationContract.cs
│ ├── IntValidationContract.cs
│ ├── ListValidationContract.cs
│ ├── LongValidationContract.cs
│ ├── ObjectValidationContract.cs
│ ├── RegexValidationContract.cs
│ ├── StringValidationContract.cs
│ ├── TimeSpanValidationContract.cs
│ └── UrlValidationContract.cs
├── Flunt.Samples/
│ ├── Entities/
│ │ ├── Contracts/
│ │ │ ├── CreateCustomerContract.cs
│ │ │ └── UpdateCustomerBirthDateContract.cs
│ │ ├── Customer.cs
│ │ ├── Entity.cs
│ │ ├── Order.cs
│ │ └── OrderLine.cs
│ ├── Flunt.Samples.csproj
│ ├── Handlers/
│ │ ├── CustomerHandler.cs
│ │ └── Requests/
│ │ ├── Contracts/
│ │ │ └── CreateCustomerRequestContract.cs
│ │ └── CreateCustomerRequest.cs
│ ├── Program.cs
│ └── ValueObjects/
│ ├── Contracts/
│ │ └── CreateEmailContract.cs
│ └── Email.cs
├── Flunt.Tests/
│ ├── BoolValidationTests.cs
│ ├── CreditCardValidationTests.cs
│ ├── CustomNotificationsTests.cs
│ ├── DateTimeValidationTests.cs
│ ├── DecimalValidationTests.cs
│ ├── DocumentValidationTests.cs
│ ├── DoubleValidationTests.cs
│ ├── EmailValidationTests.cs
│ ├── Entities/
│ │ └── SampleEntity.cs
│ ├── Enums/
│ │ └── SampleEnum.cs
│ ├── FloatValidationTests.cs
│ ├── Flunt.Tests.csproj
│ ├── GuidValidationTests.cs
│ ├── IntValidationTests.cs
│ ├── ListValidationTests.cs
│ ├── LongValidationTests.cs
│ ├── ObjectValidationTests.cs
│ ├── RegexValidationTests.cs
│ ├── StringValidationTests.cs
│ ├── TimeSpanValidationTests.cs
│ └── UrlValidationTests.cs
├── Flunt.sln
├── LICENSE
└── README.md
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/main.yml
================================================
name: Build and deploy package
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Test
run: dotnet test
- name: Create the Package
run: dotnet pack --configuration Release
- name: Publish
run: dotnet nuget push "Flunt/bin/Release/*.nupkg" -k ${{ secrets.NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json
================================================
FILE: .gitignore
================================================
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.DS_Store
.vscode
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/
================================================
FILE: Flunt/Flunt.csproj
================================================
netstandard2.0
Flunt
2.0.5
https://baltaio.blob.core.windows.net/static/images/icons/flunt-icon.png
MIT
André Baltieri
balta.io
Notifications made easy
Notifications made easy
https://github.com/andrebaltieri/Flunt
https://github.com/andrebaltieri/Flunt
MIT
icon.png
Domain;DDD;Notification;Validation;Flunt
Breaking changes from v1.5, please, visit our GitHub before migrating.
Flunt
Flunt is a fluent way to use Notification Pattern with your entities, concentrating every change you made and easy accessing it when you need.
================================================
FILE: Flunt/Localization/FluntErrorMessages.cs
================================================
namespace Flunt.Localization
{
public static class FluntErrorMessages
{
public static string AndLocalizationErrorMessageLocalization = "and";
public static string OrLocalizationErrorMessageLocalization = "or";
public static string IsFalseLocalizationErrorMessage = $"should not be true";
public static string IsTrueLocalizationErrorMessage = $"should not be false";
public static string IsEmptyLocalizationErrorMessage = $"should be empty";
public static string IsNotEmptyLocalizationErrorMessage = $"should not be empty";
public static string IsNotNullOrEmptyLocalizationErrorMessage = $"should not be null or empty";
public static string IsNotNullLocalizationErrorMessage = $"should not be null";
public static string IsNullLocalizationErrorMessage = $"should be null";
public static string IsNullOrEmptyLocalizationErrorMessage = $"should be null or empty";
public static string IsNullOrWhiteSpaceLocalizationErrorMessage = "should be null or white space";
public static string IsNotNullOrWhiteSpaceLocalizationErrorMessage = "should not be null or white space";
public static string IsGreaterThanLocalizationErrorMessage = $"should be greater than";
public static string IsGreaterOrEqualsThanLocalizationErrorMessage = $"should be greater or equals than";
public static string IsLowerThanLocalizationErrorMessage = $"should be lower than";
public static string IsLowerOrEqualsThanLocalizationErrorMessage = $"should be lower or equals than";
public static string IsBetweenLocalizationErrorMessage = $"should be between";
public static string IsNotBetweenLocalizationErrorMessage = $"should not be between";
public static string IsMinValueLocalizationErrorMessage = $"should be";
public static string IsNotMinValueLocalizationErrorMessage = $"should not be";
public static string IsMaxValueLocalizationErrorMessage = $"should be";
public static string IsNotMaxValueLocalizationErrorMessage = $"should not be";
public static string AreEqualsLocalizationErrorMessage = $"should be equals";
public static string AreNotEqualsLocalizationErrorMessage = $"should not be equals";
public static string ContainsLocalizationErrorMessage = $"should contain value";
public static string NotContainsLocalizationErrorMessage = $"should not contain value";
public static string IsCreditCardLocalizationErrorMessage = $"should be a credit card number";
public static string MatchesLocalizationErrorMessage = $"does not matches pattern";
public static string NotMatchesLocalizationErrorMessage = $"should not matches pattern";
public static string IsEmailLocalizationErrorMessage = $"should be an email";
public static string IsEmailOrEmptyLocalizationErrorMessage = $"should be an email or empty";
public static string IsNotEmailLocalizationErrorMessage = $"should not be an email";
public static string IsUrlLocalizationErrorMessage = "should be an URL";
public static string IsNotUrlLocalizationErrorMessage = "should not be an URL";
public static string IsPassportLocalizationErrorMessage = "should be a passport number";
public static string IsFalseErrorMessage(string key) => $"{key} {IsFalseLocalizationErrorMessage}";
public static string IsTrueErrorMessage(string key) => $"{key} {IsTrueLocalizationErrorMessage}";
public static string IsEmptyErrorMessage(string key) => $"{key} {IsEmptyLocalizationErrorMessage}";
public static string IsNotEmptyErrorMessage(string key) => $"{key} {IsNotEmptyLocalizationErrorMessage}";
public static string IsNotNullOrEmptyErrorMessage(string key) => $"{key} {IsNotNullOrEmptyLocalizationErrorMessage}";
public static string IsNotNullErrorMessage(string key) => $"{key} {IsNotNullLocalizationErrorMessage}";
public static string IsNullErrorMessage(string key) => $"{key} {IsNullLocalizationErrorMessage}";
public static string IsNullOrEmptyErrorMessage(string key) => $"{key} {IsNullOrEmptyLocalizationErrorMessage}";
public static string IsNullOrWhiteSpaceErrorMessage(string key) => $"{key} {IsNullOrWhiteSpaceLocalizationErrorMessage}";
public static string IsNotNullOrWhiteSpaceErrorMessage(string key) => $"{key} {IsNotNullOrWhiteSpaceLocalizationErrorMessage}";
public static string IsGreaterThanErrorMessage(string key, string comparer) => $"{key} {IsGreaterThanLocalizationErrorMessage} {comparer}";
public static string IsGreaterOrEqualsThanErrorMessage(string key, string comparer) => $"{key} {IsGreaterOrEqualsThanLocalizationErrorMessage} {comparer}";
public static string IsLowerThanErrorMessage(string key, string comparer) => $"{key} {IsLowerThanLocalizationErrorMessage} {comparer}";
public static string IsLowerOrEqualsThanErrorMessage(string key, string comparer) => $"{key} {IsLowerOrEqualsThanLocalizationErrorMessage} {comparer}";
public static string IsBetweenErrorMessage(string key, string start, string end) => $"{key} {IsBetweenLocalizationErrorMessage} {start} {AndLocalizationErrorMessageLocalization} {end}";
public static string IsNotBetweenErrorMessage(string key, string start, string end) => $"{key} {IsNotBetweenLocalizationErrorMessage} {start} {AndLocalizationErrorMessageLocalization} {end}";
public static string IsMinValueErrorMessage(string key, string minValue) => $"{key} {IsMinValueLocalizationErrorMessage} {minValue}";
public static string IsNotMinValueErrorMessage(string key, string minValue) => $"{key} {IsNotMinValueLocalizationErrorMessage} {minValue}";
public static string IsMaxValueErrorMessage(string key, string maxValue) => $"{key} {IsMaxValueLocalizationErrorMessage} {maxValue}";
public static string IsNotMaxValueErrorMessage(string key, string maxValue) => $"{key} {IsNotMaxValueLocalizationErrorMessage} {maxValue}";
public static string AreEqualsErrorMessage(string val, string comparer) => $"{val} {AreEqualsLocalizationErrorMessage} {comparer}";
public static string AreNotEqualsErrorMessage(string val, string comparer) => $"{val} {AreNotEqualsLocalizationErrorMessage} {comparer}";
public static string ContainsErrorMessage(string key, string comparer) => $"{key} {ContainsLocalizationErrorMessage} {comparer}";
public static string NotContainsErrorMessage(string key, string comparer) => $"{key} {NotContainsLocalizationErrorMessage} {comparer}";
public static string IsCreditCardErrorMessage(string key) => $"{key} {IsCreditCardLocalizationErrorMessage}";
public static string MatchesErrorMessage(string key, string pattern) => $"{key} {MatchesLocalizationErrorMessage} {pattern}";
public static string NotMatchesErrorMessage(string key, string pattern) => $"{key} {NotMatchesLocalizationErrorMessage} {pattern}";
public static string IsEmailErrorMessage(string key) => $"{key} {IsEmailLocalizationErrorMessage}";
public static string IsEmailOrEmptyErrorMessage(string key) => $"{key}{IsEmailOrEmptyLocalizationErrorMessage}";
public static string IsNotEmailErrorMessage(string key) => $"{key} {IsNotEmailLocalizationErrorMessage}";
public static string IsUrlErrorMessage(string key) => $"{key} {IsUrlLocalizationErrorMessage}";
public static string IsNotUrlErrorMessage(string key) => $"{key} {IsNotUrlLocalizationErrorMessage}";
public static string IsUrlOrEmptyErrorMessage(string key) => $"{key} {IsUrlLocalizationErrorMessage} {OrLocalizationErrorMessageLocalization} {IsEmptyLocalizationErrorMessage}";
public static string IsNotUrlOrEmptyErrorMessage(string key) => $"{key} {IsNotUrlLocalizationErrorMessage} {OrLocalizationErrorMessageLocalization} {IsEmptyLocalizationErrorMessage}";
public static string IsPassportErrorMessage(string key) => $"{key} {IsPassportLocalizationErrorMessage}";
}
}
================================================
FILE: Flunt/Localization/FluntFormats.cs
================================================
namespace Flunt.Localization
{
public static class FluntFormats
{
public static string DateFormat = "MM/DD/yyyy";
public static string DateTimeFormat = "MM/DD/yyyy hh:mm";
}
}
================================================
FILE: Flunt/Localization/FluntRegexPatterns.cs
================================================
namespace Flunt.Localization
{
public static class FluntRegexPatterns
{
public static string EmailRegexPattern = @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";
public static string UrlRegexPattern = @"^(http|https):(\/\/www\.|\/\/www\.|\/\/|\/\/)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$|(http|https):(\/\/localhost:\d*|\/\/127\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))(:[0-9]{1,5})?(\/.*)?$";
public static string OnlyNumbersPattern = @"[^0-9]+";
public static string OnlyLettersAndNumbersPattern = @"[A-Za-z0-9_-]";
public static string PassportRegexPattern = @"^(?!^0+$)[a-zA-Z0-9]{3,20}$";
}
}
================================================
FILE: Flunt/Notifications/INotifiable.cs
================================================
using System.Collections.Generic;
namespace Flunt.Notifications
{
public interface INotifiable
{
void AddNotifications(IEnumerable notifications);
}
}
================================================
FILE: Flunt/Notifications/Notifiable.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
namespace Flunt.Notifications
{
public abstract class Notifiable where T : Notification
{
private readonly List _notifications;
protected Notifiable() => _notifications = new List();
private T GetNotificationInstance(string key, string message)
{
return (T)Activator.CreateInstance(typeof(T), new object[] { key, message });
}
public IReadOnlyCollection Notifications => _notifications;
public void AddNotification(string key, string message)
{
var notification = GetNotificationInstance(key, message);
_notifications.Add(notification);
}
public void AddNotification(T notification)
{
_notifications.Add(notification);
}
public void AddNotification(Type property, string message)
{
var notification = GetNotificationInstance(property?.Name, message);
_notifications.Add(notification);
}
public void AddNotifications(IReadOnlyCollection notifications)
{
_notifications.AddRange(notifications);
}
public void AddNotifications(IList notifications)
{
_notifications.AddRange(notifications);
}
public void AddNotifications(ICollection notifications)
{
_notifications.AddRange(notifications);
}
public void AddNotifications(Notifiable item)
{
AddNotifications(item.Notifications);
}
public void AddNotifications(params Notifiable[] items)
{
foreach (var item in items)
AddNotifications(item);
}
public void Clear()
{
_notifications.Clear();
}
public bool IsValid => _notifications.Any() == false;
}
}
================================================
FILE: Flunt/Notifications/Notification.cs
================================================
namespace Flunt.Notifications
{
public class Notification
{
public Notification()
{
}
public Notification(string key, string message)
{
Key = key;
Message = message;
}
public string Key { get; set; }
public string Message { get; set; }
}
}
================================================
FILE: Flunt/Validations/BoolValidationContract.cs
================================================
using Flunt.Localization;
namespace Flunt.Validations
{
public partial class Contract
{
#region IsFalse
///
/// Requires that a bool is false
///
/// bool
/// Key or Property Name
///
public Contract IsFalse(bool val, string property) =>
IsFalse(val, property, FluntErrorMessages.IsFalseErrorMessage(property));
///
/// Requires that a bool is false
///
/// bool
/// Key or Property Name
/// Custom error message
///
public Contract IsFalse(bool val, string property, string message)
{
if (val == true)
AddNotification(property, message);
return this;
}
#endregion
#region IsTrue
///
/// Requires that a bool is true
///
/// bool
/// Key or Property Name
///
public Contract IsTrue(bool val, string property) =>
IsTrue(val, property, FluntErrorMessages.IsTrueErrorMessage(property));
///
/// Requires that a bool is true
///
/// bool
/// Key or Property Name
/// Custom error message
///
public Contract IsTrue(bool val, string property, string message)
{
if (val == false)
AddNotification(property, message);
return this;
}
#endregion
#region IsNull
///
/// Requires that a bool is null
///
/// bool
/// Key or Property Name
///
public Contract IsNull(bool? val, string property) =>
IsNull(val, property, FluntErrorMessages.IsNullErrorMessage(property));
///
/// Requires that a bool is null
///
/// bool
/// Key or Property Name
/// Custom error message
///
public Contract IsNull(bool? val, string property, string message)
{
if (val != null)
AddNotification(property, message);
return this;
}
#endregion
#region IsNotNull
///
/// Requires that a bool is not null
///
/// bool
/// Key or Property Name
///
public Contract IsNotNull(bool? val, string property) =>
IsNotNull(val, property, FluntErrorMessages.IsNotNullErrorMessage(property));
///
/// Requires that a bool is not null
///
/// bool
/// Key or Property Name
/// Custom error message
///
public Contract IsNotNull(bool? val, string property, string message)
{
if (val == null)
AddNotification(property, message);
return this;
}
#endregion
}
}
================================================
FILE: Flunt/Validations/Contract.cs
================================================
using Flunt.Notifications;
using System;
namespace Flunt.Validations
{
public partial class Contract : Notifiable
{
public Contract Requires()
{
return this;
}
public Contract Join(params Notifiable[] items)
{
if (items == null) return this;
foreach (var notifiable in items)
{
if (notifiable.IsValid == false)
AddNotifications(notifiable.Notifications);
}
return this;
}
}
}
================================================
FILE: Flunt/Validations/CreditCardValidation.cs
================================================
using System.Linq;
using System.Text.RegularExpressions;
using Flunt.Localization;
namespace Flunt.Validations
{
public partial class Contract
{
///
/// Requires a string is a Credit Card number
///
///
///
///
public Contract IsCreditCard(string val, string key) =>
IsCreditCard(val, key, FluntErrorMessages.IsCreditCardErrorMessage(key));
///
/// Requires a string is a Credit Card number
///
///
///
///
///
public Contract IsCreditCard(string val, string key, string message)
{
val = Regex.Replace(val, FluntRegexPatterns.OnlyNumbersPattern, "");
if (string.IsNullOrWhiteSpace(val))
{
AddNotification(key, message);
return this;
}
var even = false;
var checksum = 0;
foreach (var digit in val.ToCharArray().Reverse())
{
if (!char.IsDigit(digit))
{
AddNotification(val, message);
return this;
}
var value = (digit - '0') * (even ? 2 : 1);
even = !even;
while (value > 0)
{
checksum += value % 10;
value /= 10;
}
}
if (checksum % 10 != 0)
AddNotification(key, message);
return this;
}
}
}
================================================
FILE: Flunt/Validations/DateTimeValidationContract.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using Flunt.Localization;
namespace Flunt.Validations
{
public partial class Contract
{
#region IsGreaterThan
///
/// Requires a date is greater than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsGreaterThan(DateTime val, DateTime comparer, string key) =>
IsGreaterThan(val, comparer, key, FluntErrorMessages.IsGreaterThanErrorMessage(key, comparer.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a date is greater than
///
/// val
/// comparer
/// Key or Property Name
/// Customer error message
///
public Contract IsGreaterThan(DateTime val, DateTime comparer, string key, string message)
{
if (val <= comparer)
AddNotification(key, message);
return this;
}
#endregion
#region IsGreaterOrEqualsThan
///
/// Requires a date is greater or equals than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsGreaterOrEqualsThan(DateTime val, DateTime comparer, string key) =>
IsGreaterOrEqualsThan(val, comparer, key, FluntErrorMessages.IsGreaterOrEqualsThanErrorMessage(key, comparer.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a date is greater or equals than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsGreaterOrEqualsThan(DateTime val, DateTime comparer, string key, string message)
{
if (val < comparer)
AddNotification(key, message);
return this;
}
#endregion
#region IsLowerThan
///
/// Requires a date is lower than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsLowerThan(DateTime val, DateTime comparer, string key) =>
IsLowerThan(val, comparer, key, FluntErrorMessages.IsLowerThanErrorMessage(key, comparer.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a date is lower than
///
/// val
/// comparer
/// Key or Property Name
/// Customer error message
///
public Contract IsLowerThan(DateTime val, DateTime comparer, string key, string message)
{
if (val >= comparer)
AddNotification(key, message);
return this;
}
#endregion
#region IsLowerOrEqualsThan
///
/// Requires a date is lower or equals than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsLowerOrEqualsThan(DateTime val, DateTime comparer, string key) =>
IsLowerOrEqualsThan(val, comparer, key, FluntErrorMessages.IsLowerOrEqualsThanErrorMessage(key, comparer.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a date is lower or equals than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsLowerOrEqualsThan(DateTime val, DateTime comparer, string key, string message)
{
if (val > comparer)
AddNotification(key, message);
return this;
}
#endregion
#region IsNull
///
/// Requires a date is null
///
/// date
/// Key or Property Name
///
public Contract IsNull(DateTime? val, string key) =>
IsNull(val, key, FluntErrorMessages.IsNullErrorMessage(key));
///
/// Requires a date is null
///
/// date
/// Key or Property Name
/// Custom error message
///
public Contract IsNull(DateTime? val, string key, string message)
{
if (val != null)
AddNotification(key, message);
return this;
}
#endregion
#region IsNotNull
///
/// Requires a date is not null
///
/// date
/// Key or Property Name
///
public Contract IsNotNull(DateTime? val, string key) =>
IsNotNull(val, key, FluntErrorMessages.IsNotNullErrorMessage(key));
///
/// Requires a date is not null
///
/// date
/// Key or Property Name
/// Custom error message
///
public Contract IsNotNull(DateTime? val, string key, string message)
{
if (val == null)
AddNotification(key, message);
return this;
}
#endregion
#region IsBetween
///
/// Requires a date is between
///
/// date
/// start date
/// end date
/// Key or Property Name
///
public Contract IsBetween(DateTime val, DateTime start, DateTime end, string key) =>
IsBetween(val, start, end, key, FluntErrorMessages.IsBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a date is between
///
/// date
/// start date
/// end date
/// Key or Property Name
/// Customer error message
///
public Contract IsBetween(DateTime val, DateTime start, DateTime end, string key, string message)
{
if ((val >= start && val <= end) == false)
AddNotification(key, message);
return this;
}
#endregion
#region IsNotBetween
///
/// Requires a date is not between
///
/// date
/// start date
/// end date
/// Key or Property Name
///
public Contract IsNotBetween(DateTime val, DateTime start, DateTime end, string key) =>
IsNotBetween(val, start, end, key, FluntErrorMessages.IsNotBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a date is not between
///
/// date
/// start date
/// end date
/// Key or Property Name
/// Customer error message
///
public Contract IsNotBetween(DateTime val, DateTime start, DateTime end, string key, string message)
{
if ((val >= start && val <= end) == true)
AddNotification(key, message);
return this;
}
#endregion
#region IsMinValue
///
/// Requires a date is min value
///
/// date
/// Key or Property Name
///
public Contract IsMinValue(DateTime val, string key) =>
IsMinValue(val, key, FluntErrorMessages.IsMinValueErrorMessage(key, DateTime.MinValue.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a date is min value
///
/// date
/// Key or Property Name
/// Custom error message
///
public Contract IsMinValue(DateTime val, string key, string message)
{
if (val != DateTime.MinValue)
AddNotification(key, message);
return this;
}
#endregion
#region IsNotMinValue
///
/// Requires a date is not min value
///
/// date
/// Key or Property Name
///
public Contract IsNotMinValue(DateTime val, string key) =>
IsNotMinValue(val, key, FluntErrorMessages.IsNotMinValueErrorMessage(key, DateTime.MinValue.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a date is not min value
///
/// date
/// Key or Property Name
/// Custom error message
///
public Contract IsNotMinValue(DateTime val, string key, string message)
{
if (val == DateTime.MinValue)
AddNotification(key, message);
return this;
}
#endregion
#region IsMaxValue
///
/// Requires a date is max value
///
/// date
/// Key or Property Name
///
public Contract IsMaxValue(DateTime val, string key) =>
IsMaxValue(val, key, FluntErrorMessages.IsMaxValueErrorMessage(key, DateTime.MaxValue.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a date is max value
///
/// date
/// Key or Property Name
/// Custom error message
///
public Contract IsMaxValue(DateTime val, string key, string message)
{
if (val != DateTime.MaxValue)
AddNotification(key, message);
return this;
}
#endregion
#region IsNotMaxValue
///
/// Requires a date is not max value
///
/// date
/// Key or Property Name
///
public Contract IsNotMaxValue(DateTime val, string key) =>
IsNotMaxValue(val, key, FluntErrorMessages.IsNotMaxValueErrorMessage(key, DateTime.MaxValue.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a date is not max value
///
/// date
/// Key or Property Name
/// Custom error message
///
public Contract IsNotMaxValue(DateTime val, string key, string message)
{
if (val == DateTime.MaxValue)
AddNotification(key, message);
return this;
}
#endregion
#region AreEquals
///
/// Require dates are equals
///
/// date
/// date
/// Key or Property Name
///
public Contract AreEquals(DateTime val, DateTime comparer, string key)
=> AreEquals(val, comparer, key, FluntErrorMessages.AreEqualsErrorMessage(val.ToString(FluntFormats.DateTimeFormat), comparer.ToString(FluntFormats.DateTimeFormat)));
///
/// Require dates are equals
///
/// date
/// date
/// Key or Property Name
/// Customer error message
///
public Contract AreEquals(DateTime val, DateTime comparer, string key, string message)
{
if (val != comparer)
AddNotification(key, message);
return this;
}
#endregion
#region AreNotEquals
///
/// Requires two dates are not equals
///
/// date
/// date
/// Key or Property Name
///
public Contract AreNotEquals(DateTime val, DateTime comparer, string key)
=> AreNotEquals(val, comparer, key, FluntErrorMessages.AreNotEqualsErrorMessage(val.ToString(FluntFormats.DateTimeFormat), comparer.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires two dates are not equals
///
/// date
/// date
/// Key or Property Name
/// Custom error message
///
public Contract AreNotEquals(DateTime val, DateTime comparer, string key, string message)
{
if (val == comparer)
AddNotification(key, message);
return this;
}
#endregion
#region Contains
///
/// Requires a list contains a date
///
/// date
/// list of dates
/// Key or Property Name
///
public Contract Contains(DateTime val, IEnumerable list, string key)
=> Contains(val, list, key, FluntErrorMessages.ContainsErrorMessage(key, val.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a list contains a date
///
/// date
/// list of dates
/// Key or Property Name
/// Custom error message
///
public Contract Contains(DateTime val, IEnumerable list, string key, string message)
{
if (list.Any(x => x == val) == false)
AddNotification(key, message);
return this;
}
#endregion
#region NotContains
///
/// Requires a list not contains a date
///
/// date
/// list of dates
/// Key or Property Name
///
public Contract NotContains(DateTime val, IEnumerable list, string key)
=> NotContains(val, list, key, FluntErrorMessages.NotContainsErrorMessage(key, val.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a list not contains a date
///
/// date
/// list of dates
/// Key or Property Name
/// Custom error message
///
public Contract NotContains(DateTime val, IEnumerable list, string key, string message)
{
if (list.Any(x => x == val) == true)
AddNotification(key, message);
return this;
}
#endregion
}
}
================================================
FILE: Flunt/Validations/DecimalValidationContract.cs
================================================
using System.Collections.Generic;
using System.Linq;
using Flunt.Localization;
namespace Flunt.Validations
{
public partial class Contract
{
#region IsGreaterThan
///
/// Requires a decimal is greater than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsGreaterThan(decimal val, decimal comparer, string key) =>
IsGreaterThan(val, comparer, key, FluntErrorMessages.IsGreaterThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is greater than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsGreaterThan(decimal val, decimal comparer, string key, string message)
{
if (val <= comparer)
AddNotification(key, message);
return this;
}
///
/// Requires a decimal is greater than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsGreaterThan(decimal val, double comparer, string key) =>
IsGreaterThan(val, comparer, key, FluntErrorMessages.IsGreaterThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is greater than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsGreaterThan(decimal val, double comparer, string key, string message) =>
IsGreaterThan(val, (decimal)comparer, key, message);
///
/// Requires a decimal is greater than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsGreaterThan(decimal val, float comparer, string key) =>
IsGreaterThan(val, comparer, key, FluntErrorMessages.IsGreaterThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is greater than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsGreaterThan(decimal val, float comparer, string key, string message) =>
IsGreaterThan(val, (decimal)comparer, key, message);
///
/// Requires a decimal is greater than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsGreaterThan(decimal val, int comparer, string key) =>
IsGreaterThan(val, comparer, key, FluntErrorMessages.IsGreaterThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is greater than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsGreaterThan(decimal val, int comparer, string key, string message) =>
IsGreaterThan(val, (decimal)comparer, key, message);
///
/// Requires a decimal is greater than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsGreaterThan(decimal val, long comparer, string key) =>
IsGreaterThan(val, comparer, key, FluntErrorMessages.IsGreaterThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is greater than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsGreaterThan(decimal val, long comparer, string key, string message) =>
IsGreaterThan(val, (decimal)comparer, key, message);
#endregion
#region IsGreaterOrEqualsThan
///
/// Requires a decimal is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsGreaterOrEqualsThan(decimal val, decimal comparer, string key) =>
IsGreaterOrEqualsThan(val, comparer, key, FluntErrorMessages.IsGreaterOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsGreaterOrEqualsThan(decimal val, decimal comparer, string key, string message)
{
if (val < comparer)
AddNotification(key, message);
return this;
}
///
/// Requires a decimal is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsGreaterOrEqualsThan(decimal val, double comparer, string key) =>
IsGreaterOrEqualsThan(val, (decimal)comparer, key, FluntErrorMessages.IsGreaterOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsGreaterOrEqualsThan(decimal val, double comparer, string key, string message) =>
IsGreaterOrEqualsThan(val, (decimal)comparer, key, message);
///
/// Requires a decimal is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsGreaterOrEqualsThan(decimal val, float comparer, string key) =>
IsGreaterOrEqualsThan(val, (decimal)comparer, key, FluntErrorMessages.IsGreaterOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsGreaterOrEqualsThan(decimal val, float comparer, string key, string message) =>
IsGreaterOrEqualsThan(val, (decimal)comparer, key, message);
///
/// Requires a decimal is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsGreaterOrEqualsThan(decimal val, int comparer, string key) =>
IsGreaterOrEqualsThan(val, (decimal)comparer, key, FluntErrorMessages.IsGreaterOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsGreaterOrEqualsThan(decimal val, int comparer, string key, string message) =>
IsGreaterOrEqualsThan(val, (decimal)comparer, key, message);
///
/// Requires a decimal is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsGreaterOrEqualsThan(decimal val, long comparer, string key) =>
IsGreaterOrEqualsThan(val, (decimal)comparer, key, FluntErrorMessages.IsGreaterOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsGreaterOrEqualsThan(decimal val, long comparer, string key, string message) =>
IsGreaterOrEqualsThan(val, (decimal)comparer, key, message);
#endregion
#region IsLowerThan
///
/// Requires a decimal is lower than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsLowerThan(decimal val, decimal comparer, string key) =>
IsLowerThan(val, comparer, key, FluntErrorMessages.IsLowerThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is lower than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsLowerThan(decimal val, decimal comparer, string key, string message)
{
if (val >= comparer)
AddNotification(key, message);
return this;
}
///
/// Requires a decimal is lower than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsLowerThan(decimal val, double comparer, string key) =>
IsLowerThan(val, comparer, key, FluntErrorMessages.IsLowerThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is lower than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsLowerThan(decimal val, double comparer, string key, string message) =>
IsLowerThan(val, (decimal)comparer, key, message);
///
/// Requires a decimal is lower than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsLowerThan(decimal val, float comparer, string key) =>
IsLowerThan(val, comparer, key, FluntErrorMessages.IsLowerThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is lower than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsLowerThan(decimal val, float comparer, string key, string message) =>
IsLowerThan(val, (decimal)comparer, key, message);
///
/// Requires a decimal is lower than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsLowerThan(decimal val, int comparer, string key) =>
IsLowerThan(val, comparer, key, FluntErrorMessages.IsLowerThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is lower than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsLowerThan(decimal val, int comparer, string key, string message) =>
IsLowerThan(val, (decimal)comparer, key, message);
///
/// Requires a decimal is lower than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsLowerThan(decimal val, long comparer, string key) =>
IsLowerThan(val, comparer, key, FluntErrorMessages.IsLowerThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is lower than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsLowerThan(decimal val, long comparer, string key, string message) =>
IsLowerThan(val, (decimal)comparer, key, message);
#endregion
#region IsLowerOrEqualsThan
///
/// Requires a decimal is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsLowerOrEqualsThan(decimal val, decimal comparer, string key) =>
IsLowerOrEqualsThan(val, comparer, key, FluntErrorMessages.IsLowerOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsLowerOrEqualsThan(decimal val, decimal comparer, string key, string message)
{
if (val > comparer)
AddNotification(key, message);
return this;
}
///
/// Requires a decimal is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsLowerOrEqualsThan(decimal val, double comparer, string key) =>
IsLowerOrEqualsThan(val, (decimal)comparer, key, FluntErrorMessages.IsLowerOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsLowerOrEqualsThan(decimal val, double comparer, string key, string message) =>
IsLowerOrEqualsThan(val, (decimal)comparer, key, message);
///
/// Requires a decimal is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsLowerOrEqualsThan(decimal val, float comparer, string key) =>
IsLowerOrEqualsThan(val, (decimal)comparer, key, FluntErrorMessages.IsLowerOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsLowerOrEqualsThan(decimal val, float comparer, string key, string message) =>
IsLowerOrEqualsThan(val, (decimal)comparer, key, message);
///
/// Requires a decimal is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsLowerOrEqualsThan(decimal val, int comparer, string key) =>
IsLowerOrEqualsThan(val, (decimal)comparer, key, FluntErrorMessages.IsLowerOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsLowerOrEqualsThan(decimal val, int comparer, string key, string message) =>
IsLowerOrEqualsThan(val, (decimal)comparer, key, message);
///
/// Requires a decimal is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsLowerOrEqualsThan(decimal val, long comparer, string key) =>
IsLowerOrEqualsThan(val, (decimal)comparer, key, FluntErrorMessages.IsLowerOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a decimal is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsLowerOrEqualsThan(decimal val, long comparer, string key, string message) =>
IsLowerOrEqualsThan(val, (decimal)comparer, key, message);
#endregion
#region IsMinValue
///
/// Requires a decimal has its min value
///
///
///
///
public Contract IsMinValue(decimal val, string key) =>
IsMinValue(val, key, FluntErrorMessages.IsMinValueErrorMessage(key, decimal.MinValue.ToString()));
///
/// Requires a decimal has its min value
///
///
///
///
///
public Contract IsMinValue(decimal val, string key, string message)
{
if (val != decimal.MinValue)
AddNotification(key, message);
return this;
}
#endregion
#region IsNotMinValue
///
/// Requires a decimal has not its min value
///
///
///
///
public Contract IsNotMinValue(decimal val, string key) =>
IsNotMinValue(val, key, FluntErrorMessages.IsNotMinValueErrorMessage(key, decimal.MinValue.ToString()));
///
/// Requires a decimal has not its min value
///
///
///
///
///
public Contract IsNotMinValue(decimal val, string key, string message)
{
if (val == decimal.MinValue)
AddNotification(key, message);
return this;
}
#endregion
#region IsMaxValue
///
/// Requires a decimal has its max value
///
///
///
///
public Contract IsMaxValue(decimal val, string key) =>
IsMaxValue(val, key, FluntErrorMessages.IsMaxValueErrorMessage(key, decimal.MaxValue.ToString()));
///
/// Requires a decimal has its max value
///
///
///
///
///
public Contract IsMaxValue(decimal val, string key, string message)
{
if (val != decimal.MaxValue)
AddNotification(key, message);
return this;
}
#endregion
#region IsNotMaxValue
///
/// Requires a decimal has not its max value
///
///
///
///
public Contract IsNotMaxValue(decimal val, string key) =>
IsNotMaxValue(val, key, FluntErrorMessages.IsNotMaxValueErrorMessage(key, decimal.MaxValue.ToString()));
///
/// Requires a decimal has not its min value
///
///
///
///
///
public Contract IsNotMaxValue(decimal val, string key, string message)
{
if (val == decimal.MaxValue)
AddNotification(key, message);
return this;
}
#endregion
#region AreEquals
///
/// Requires two decimals are equals
///
///
///
///
///
///
public Contract AreEquals(decimal val, decimal comparer, string key) =>
AreEquals(val, comparer, key, FluntErrorMessages.AreEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are equals
///
///
///
///
///
///
public Contract AreEquals(decimal val, decimal comparer, string key, string message)
{
if (val != comparer)
AddNotification(key, message);
return this;
}
///
/// Requires two decimals are equals
///
///
///
///
///
public Contract AreEquals(decimal val, int comparer, string key) =>
AreEquals(val, (decimal)comparer, key, FluntErrorMessages.AreEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are equals
///
///
///
///
///
///
public Contract AreEquals(decimal val, int comparer, string key, string message) =>
AreEquals(val, (decimal)comparer, key, message);
///
/// Requires two decimals are equals
///
///
///
///
///
public Contract AreEquals(decimal val, float comparer, string key) =>
AreEquals(val, (decimal)comparer, key, FluntErrorMessages.AreEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are equals
///
///
///
///
///
///
public Contract AreEquals(decimal val, float comparer, string key, string message) =>
AreEquals(val, (decimal)comparer, key, message);
///
/// Requires two decimals are equals
///
///
///
///
///
public Contract AreEquals(decimal val, double comparer, string key) =>
AreEquals(val, (decimal)comparer, key, FluntErrorMessages.AreEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are equals
///
///
///
///
///
///
public Contract AreEquals(decimal val, double comparer, string key, string message) =>
AreEquals(val, (decimal)comparer, key, message);
///
/// Requires two decimals are equals
///
///
///
///
///
public Contract AreEquals(decimal val, long comparer, string key) =>
AreEquals(val, (decimal)comparer, key, FluntErrorMessages.AreEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are equals
///
///
///
///
///
///
public Contract AreEquals(decimal val, long comparer, string key, string message) =>
AreEquals(val, (decimal)comparer, key, message);
#endregion
#region AreNotEquals
///
/// Requires two decimals are not equals
///
///
///
///
///
///
public Contract AreNotEquals(decimal val, decimal comparer, string key) =>
AreNotEquals(val, comparer, key, FluntErrorMessages.AreNotEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are not equals
///
///
///
///
///
///
public Contract AreNotEquals(decimal val, decimal comparer, string key, string message)
{
if (val == comparer)
AddNotification(key, message);
return this;
}
///
/// Requires two decimals are not equals
///
///
///
///
///
public Contract AreNotEquals(decimal val, int comparer, string key) =>
AreNotEquals(val, (decimal)comparer, key, FluntErrorMessages.AreNotEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are not equals
///
///
///
///
///
///
public Contract AreNotEquals(decimal val, int comparer, string key, string message) =>
AreNotEquals(val, (decimal)comparer, key, message);
///
/// Requires two decimals are not equals
///
///
///
///
///
public Contract AreNotEquals(decimal val, float comparer, string key) =>
AreNotEquals(val, (decimal)comparer, key, FluntErrorMessages.AreNotEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are not equals
///
///
///
///
///
///
public Contract AreNotEquals(decimal val, float comparer, string key, string message) =>
AreNotEquals(val, (decimal)comparer, key, message);
///
/// Requires two decimals are not equals
///
///
///
///
///
public Contract AreNotEquals(decimal val, double comparer, string key) =>
AreNotEquals(val, (decimal)comparer, key, FluntErrorMessages.AreNotEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are not equals
///
///
///
///
///
///
public Contract AreNotEquals(decimal val, double comparer, string key, string message) =>
AreNotEquals(val, (decimal)comparer, key, message);
///
/// Requires two decimals are not equals
///
///
///
///
///
public Contract AreNotEquals(decimal val, long comparer, string key) =>
AreNotEquals(val, (decimal)comparer, key, FluntErrorMessages.AreNotEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are not equals
///
///
///
///
///
///
public Contract AreNotEquals(decimal val, long comparer, string key, string message) =>
AreNotEquals(val, (decimal)comparer, key, message);
#endregion
#region IsNull
///
/// Requires a decimal is null
///
///
///
///
public Contract IsNull(decimal? val, string key) =>
IsNull(val, key, FluntErrorMessages.IsNullErrorMessage(key));
///
/// Requires a decimal is null
///
///
///
///
///
public Contract IsNull(decimal? val, string key, string message)
{
if (val != null)
AddNotification(key, message);
return this;
}
#endregion
#region IsNotNull
///
/// Requires a decimal is not null
///
///
///
///
public Contract IsNotNull(decimal? val, string key) =>
IsNotNull(val, key, FluntErrorMessages.IsNotNullErrorMessage(key));
///
/// Requires a decimal is not null
///
///
///
///
///
public Contract IsNotNull(decimal? val, string key, string message)
{
if (val == null)
AddNotification(key, message);
return this;
}
#endregion
#region IsBetween
///
/// Requires a decimal is between
///
///
///
///
///
///
public Contract IsBetween(decimal val, decimal start, decimal end, string key) =>
IsBetween(val, start, end, key, FluntErrorMessages.IsBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a decimal is between
///
///
///
///
///
///
///
public Contract IsBetween(decimal val, decimal start, decimal end, string key, string message)
{
if ((val >= start && val <= end) == false)
AddNotification(key, message);
return this;
}
///
/// Requires a decimal is between
///
///
///
///
///
///
public Contract IsBetween(decimal val, int start, int end, string key) =>
IsBetween(val, (decimal)start, (decimal)end, key, FluntErrorMessages.IsBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a decimal is between
///
///
///
///
///
///
///
public Contract IsBetween(decimal val, int start, int end, string key, string message) =>
IsBetween(val, (decimal)start, (decimal)end, key, message);
///
/// Requires a decimal is between
///
///
///
///
///
///
public Contract IsBetween(decimal val, float start, float end, string key) =>
IsBetween(val, (decimal)start, (decimal)end, key, FluntErrorMessages.IsBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a decimal is between
///
///
///
///
///
///
///
public Contract IsBetween(decimal val, float start, float end, string key, string message) =>
IsBetween(val, (decimal)start, (decimal)end, key, message);
///
/// Requires a decimal is between
///
///
///
///
///
///
public Contract IsBetween(decimal val, double start, double end, string key) =>
IsBetween(val, (decimal)start, (decimal)end, key, FluntErrorMessages.IsBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a decimal is between
///
///
///
///
///
///
///
public Contract IsBetween(decimal val, double start, double end, string key, string message) =>
IsBetween(val, (decimal)start, (decimal)end, key, message);
///
/// Requires a decimal is between
///
///
///
///
///
///
public Contract IsBetween(decimal val, long start, long end, string key) =>
IsBetween(val, (decimal)start, (decimal)end, key, FluntErrorMessages.IsBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a decimal is between
///
///
///
///
///
///
///
public Contract IsBetween(decimal val, long start, long end, string key, string message) =>
IsBetween(val, (decimal)start, (decimal)end, key, message);
#endregion
#region IsNotBetween
///
/// Requires a decimal is not between
///
///
///
///
///
///
public Contract IsNotBetween(decimal val, decimal start, decimal end, string key) =>
IsNotBetween(val, start, end, key, FluntErrorMessages.IsNotBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a decimal is not between
///
///
///
///
///
///
///
public Contract IsNotBetween(decimal val, decimal start, decimal end, string key, string message)
{
if ((val >= start && val <= end) == true)
AddNotification(key, message);
return this;
}
///
/// Requires a decimal is not between
///
///
///
///
///
///
public Contract IsNotBetween(decimal val, int start, int end, string key) =>
IsNotBetween(val, (decimal)start, (decimal)end, key, FluntErrorMessages.IsNotBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a decimal is not between
///
///
///
///
///
///
///
public Contract IsNotBetween(decimal val, int start, int end, string key, string message) =>
IsNotBetween(val, (decimal)start, (decimal)end, key, message);
///
/// Requires a decimal is not between
///
///
///
///
///
///
public Contract IsNotBetween(decimal val, float start, float end, string key) =>
IsNotBetween(val, (decimal)start, (decimal)end, key, FluntErrorMessages.IsNotBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a decimal is not between
///
///
///
///
///
///
///
public Contract IsNotBetween(decimal val, float start, float end, string key, string message) =>
IsNotBetween(val, (decimal)start, (decimal)end, key, message);
///
/// Requires a decimal is not between
///
///
///
///
///
///
public Contract IsNotBetween(decimal val, double start, double end, string key) =>
IsNotBetween(val, (decimal)start, (decimal)end, key, FluntErrorMessages.IsNotBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a decimal is not between
///
///
///
///
///
///
///
public Contract IsNotBetween(decimal val, double start, double end, string key, string message) =>
IsNotBetween(val, (decimal)start, (decimal)end, key, message);
///
/// Requires a decimal is not between
///
///
///
///
///
///
public Contract IsNotBetween(decimal val, long start, long end, string key) =>
IsNotBetween(val, (decimal)start, (decimal)end, key, FluntErrorMessages.IsNotBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a decimal is not between
///
///
///
///
///
///
///
public Contract IsNotBetween(decimal val, long start, long end, string key, string message) =>
IsNotBetween(val, (decimal)start, (decimal)end, key, message);
#endregion
#region Contains
///
/// Requires a list contains a decimal
///
///
///
///
///
public Contract Contains(decimal val, IEnumerable list, string key) =>
Contains(val, list, key, FluntErrorMessages.ContainsErrorMessage(key, val.ToString()));
///
/// Requires a list contains a decimal
///
///
///
///
///
///
public Contract Contains(decimal val, IEnumerable list, string key, string message)
{
if (list.Any(x => x == val) == false)
AddNotification(key, message);
return this;
}
#endregion
#region NotContains
///
/// Requires a list does not contains a decimal
///
///
///
///
///
public Contract NotContains(decimal val, IEnumerable list, string key) =>
NotContains(val, list, key, FluntErrorMessages.NotContainsErrorMessage(key, val.ToString()));
///
/// Requires a list does not contains a decimal
///
///
///
///
///
///
public Contract NotContains(decimal val, IEnumerable list, string key, string message)
{
if (list.Any(x => x == val) == true)
AddNotification(key, message);
return this;
}
#endregion
}
}
================================================
FILE: Flunt/Validations/DocumentValitionContract.cs
================================================
using Flunt.Localization;
namespace Flunt.Validations
{
public partial class Contract
{
///
/// Requires a string is a passport number
///
///
///
///
public Contract IsPassport(string val, string key) =>
IsPassport(val, key, FluntErrorMessages.IsPassportErrorMessage(key));
///
/// Requires a string is a passport number
///
///
///
///
///
public Contract IsPassport(string val, string key, string message) =>
Matches(val, FluntRegexPatterns.PassportRegexPattern, key, message);
}
}
================================================
FILE: Flunt/Validations/DoubleValidationContract.cs
================================================
using System.Collections.Generic;
using System.Linq;
using Flunt.Localization;
namespace Flunt.Validations
{
public partial class Contract
{
#region IsGreaterThan
///
/// Requires a double is greater than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsGreaterThan(double val, double comparer, string key) =>
IsGreaterThan(val, comparer, key, FluntErrorMessages.IsGreaterThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is greater than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsGreaterThan(double val, double comparer, string key, string message)
{
if (val <= (double)comparer)
AddNotification(key, message);
return this;
}
///
/// Requires a double is greater than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsGreaterThan(double val, decimal comparer, string key) =>
IsGreaterThan(val, comparer, key, FluntErrorMessages.IsGreaterThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is greater than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsGreaterThan(double val, decimal comparer, string key, string message) =>
IsGreaterThan(val, (double)comparer, key, message);
///
/// Requires a double is greater than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsGreaterThan(double val, float comparer, string key) =>
IsGreaterThan(val, comparer, key, FluntErrorMessages.IsGreaterThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is greater than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsGreaterThan(double val, float comparer, string key, string message) =>
IsGreaterThan(val, (double)comparer, key, message);
///
/// Requires a double is greater than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsGreaterThan(double val, int comparer, string key) =>
IsGreaterThan(val, comparer, key, FluntErrorMessages.IsGreaterThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is greater than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsGreaterThan(double val, int comparer, string key, string message) =>
IsGreaterThan(val, (double)comparer, key, message);
///
/// Requires a double is greater than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsGreaterThan(double val, long comparer, string key) =>
IsGreaterThan(val, comparer, key, FluntErrorMessages.IsGreaterThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is greater than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsGreaterThan(double val, long comparer, string key, string message) =>
IsGreaterThan(val, (double)comparer, key, message);
#endregion
#region IsGreaterOrEqualsThan
///
/// Requires a double is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsGreaterOrEqualsThan(double val, double comparer, string key) =>
IsGreaterOrEqualsThan(val, comparer, key, FluntErrorMessages.IsGreaterOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsGreaterOrEqualsThan(double val, double comparer, string key, string message)
{
if (val < comparer)
AddNotification(key, message);
return this;
}
///
/// Requires a double is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsGreaterOrEqualsThan(double val, decimal comparer, string key) =>
IsGreaterOrEqualsThan(val, (double)comparer, key, FluntErrorMessages.IsGreaterOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsGreaterOrEqualsThan(double val, decimal comparer, string key, string message) =>
IsGreaterOrEqualsThan(val, (double)comparer, key, message);
///
/// Requires a double is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsGreaterOrEqualsThan(double val, float comparer, string key) =>
IsGreaterOrEqualsThan(val, (double)comparer, key, FluntErrorMessages.IsGreaterOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsGreaterOrEqualsThan(double val, float comparer, string key, string message) =>
IsGreaterOrEqualsThan(val, (double)comparer, key, message);
///
/// Requires a double is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsGreaterOrEqualsThan(double val, int comparer, string key) =>
IsGreaterOrEqualsThan(val, (double)comparer, key, FluntErrorMessages.IsGreaterOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsGreaterOrEqualsThan(double val, int comparer, string key, string message) =>
IsGreaterOrEqualsThan(val, (double)comparer, key, message);
///
/// Requires a double is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsGreaterOrEqualsThan(double val, long comparer, string key) =>
IsGreaterOrEqualsThan(val, (double)comparer, key, FluntErrorMessages.IsGreaterOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is greater or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsGreaterOrEqualsThan(double val, long comparer, string key, string message) =>
IsGreaterOrEqualsThan(val, (double)comparer, key, message);
#endregion
#region IsLowerThan
///
/// Requires a double is lower than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsLowerThan(double val, double comparer, string key) =>
IsLowerThan(val, comparer, key, FluntErrorMessages.IsLowerThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is lower than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsLowerThan(double val, double comparer, string key, string message)
{
if (val >= comparer)
AddNotification(key, message);
return this;
}
///
/// Requires a double is lower than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsLowerThan(double val, decimal comparer, string key) =>
IsLowerThan(val, comparer, key, FluntErrorMessages.IsLowerThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is lower than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsLowerThan(double val, decimal comparer, string key, string message) =>
IsLowerThan(val, (double)comparer, key, message);
///
/// Requires a double is lower than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsLowerThan(double val, float comparer, string key) =>
IsLowerThan(val, comparer, key, FluntErrorMessages.IsLowerThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is lower than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsLowerThan(double val, float comparer, string key, string message) =>
IsLowerThan(val, (double)comparer, key, message);
///
/// Requires a double is lower than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsLowerThan(double val, int comparer, string key) =>
IsLowerThan(val, comparer, key, FluntErrorMessages.IsLowerThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is lower than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsLowerThan(double val, int comparer, string key, string message) =>
IsLowerThan(val, (double)comparer, key, message);
///
/// Requires a double is lower than
///
/// val
/// comparer
/// Key or Property Name
///
public Contract IsLowerThan(double val, long comparer, string key) =>
IsLowerThan(val, comparer, key, FluntErrorMessages.IsLowerThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is lower than
///
/// val
/// comparer
/// Key or Property Name
/// Custom error message
///
public Contract IsLowerThan(double val, long comparer, string key, string message) =>
IsLowerThan(val, (double)comparer, key, message);
#endregion
#region IsLowerOrEqualsThan
///
/// Requires a double is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsLowerOrEqualsThan(double val, double comparer, string key) =>
IsLowerOrEqualsThan(val, comparer, key, FluntErrorMessages.IsLowerOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsLowerOrEqualsThan(double val, double comparer, string key, string message)
{
if (val > comparer)
AddNotification(key, message);
return this;
}
///
/// Requires a double is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsLowerOrEqualsThan(double val, decimal comparer, string key) =>
IsLowerOrEqualsThan(val, (double)comparer, key, FluntErrorMessages.IsLowerOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsLowerOrEqualsThan(double val, decimal comparer, string key, string message) =>
IsLowerOrEqualsThan(val, (double)comparer, key, message);
///
/// Requires a double is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsLowerOrEqualsThan(double val, float comparer, string key) =>
IsLowerOrEqualsThan(val, (double)comparer, key, FluntErrorMessages.IsLowerOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsLowerOrEqualsThan(double val, float comparer, string key, string message) =>
IsLowerOrEqualsThan(val, (double)comparer, key, message);
///
/// Requires a double is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsLowerOrEqualsThan(double val, int comparer, string key) =>
IsLowerOrEqualsThan(val, (double)comparer, key, FluntErrorMessages.IsLowerOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsLowerOrEqualsThan(double val, int comparer, string key, string message) =>
IsLowerOrEqualsThan(val, (double)comparer, key, message);
///
/// Requires a double is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
///
public Contract IsLowerOrEqualsThan(double val, long comparer, string key) =>
IsLowerOrEqualsThan(val, (double)comparer, key, FluntErrorMessages.IsLowerOrEqualsThanErrorMessage(key, comparer.ToString()));
///
/// Requires a double is lower or equals than
///
/// val
/// comparer
/// Key or Property Message
/// Customer error message
///
public Contract IsLowerOrEqualsThan(double val, long comparer, string key, string message) =>
IsLowerOrEqualsThan(val, (double)comparer, key, message);
#endregion
#region IsMinValue
///
/// Requires a double has its min value
///
///
///
///
public Contract IsMinValue(double val, string key) =>
IsMinValue(val, key, FluntErrorMessages.IsMinValueErrorMessage(key, double.MinValue.ToString()));
///
/// Requires a double has its min value
///
///
///
///
///
public Contract IsMinValue(double val, string key, string message)
{
if (val != double.MinValue)
AddNotification(key, message);
return this;
}
#endregion
#region IsNotMinValue
///
/// Requires a double has not its min value
///
///
///
///
public Contract IsNotMinValue(double val, string key) =>
IsNotMinValue(val, key, FluntErrorMessages.IsNotMinValueErrorMessage(key, double.MinValue.ToString()));
///
/// Requires a double has not its min value
///
///
///
///
///
public Contract IsNotMinValue(double val, string key, string message)
{
if (val == double.MinValue)
AddNotification(key, message);
return this;
}
#endregion
#region IsMaxValue
///
/// Requires a double has its max value
///
///
///
///
public Contract IsMaxValue(double val, string key) =>
IsMaxValue(val, key, FluntErrorMessages.IsMaxValueErrorMessage(key, double.MaxValue.ToString()));
///
/// Requires a double has its max value
///
///
///
///
///
public Contract IsMaxValue(double val, string key, string message)
{
if (val != double.MaxValue)
AddNotification(key, message);
return this;
}
#endregion
#region IsNotMaxValue
///
/// Requires a double has not its max value
///
///
///
///
public Contract IsNotMaxValue(double val, string key) =>
IsNotMaxValue(val, key, FluntErrorMessages.IsNotMaxValueErrorMessage(key, double.MaxValue.ToString()));
///
/// Requires a double has not its min value
///
///
///
///
///
public Contract IsNotMaxValue(double val, string key, string message)
{
if (val == double.MaxValue)
AddNotification(key, message);
return this;
}
#endregion
#region AreEquals
///
/// Requires two decimals are equals
///
///
///
///
///
///
public Contract AreEquals(double val, double comparer, string key) =>
AreEquals(val, comparer, key, FluntErrorMessages.AreEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are equals
///
///
///
///
///
///
public Contract AreEquals(double val, double comparer, string key, string message)
{
if (val != comparer)
AddNotification(key, message);
return this;
}
///
/// Requires two decimals are equals
///
///
///
///
///
public Contract AreEquals(double val, int comparer, string key) =>
AreEquals(val, (double)comparer, key, FluntErrorMessages.AreEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are equals
///
///
///
///
///
///
public Contract AreEquals(double val, int comparer, string key, string message) =>
AreEquals(val, (double)comparer, key, message);
///
/// Requires two decimals are equals
///
///
///
///
///
public Contract AreEquals(double val, float comparer, string key) =>
AreEquals(val, (double)comparer, key, FluntErrorMessages.AreEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are equals
///
///
///
///
///
///
public Contract AreEquals(double val, float comparer, string key, string message) =>
AreEquals(val, (double)comparer, key, message);
///
/// Requires two decimals are equals
///
///
///
///
///
public Contract AreEquals(double val, decimal comparer, string key) =>
AreEquals(val, (double)comparer, key, FluntErrorMessages.AreEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are equals
///
///
///
///
///
///
public Contract AreEquals(double val, decimal comparer, string key, string message) =>
AreEquals(val, (double)comparer, key, message);
///
/// Requires two decimals are equals
///
///
///
///
///
public Contract AreEquals(double val, long comparer, string key) =>
AreEquals(val, (double)comparer, key, FluntErrorMessages.AreEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are equals
///
///
///
///
///
///
public Contract AreEquals(double val, long comparer, string key, string message) =>
AreEquals(val, (double)comparer, key, message);
#endregion
#region AreNotEquals
///
/// Requires two decimals are not equals
///
///
///
///
///
///
public Contract AreNotEquals(double val, double comparer, string key) =>
AreNotEquals(val, comparer, key, FluntErrorMessages.AreNotEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are not equals
///
///
///
///
///
///
public Contract AreNotEquals(double val, double comparer, string key, string message)
{
if (val == comparer)
AddNotification(key, message);
return this;
}
///
/// Requires two decimals are not equals
///
///
///
///
///
public Contract AreNotEquals(double val, int comparer, string key) =>
AreNotEquals(val, (double)comparer, key, FluntErrorMessages.AreNotEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are not equals
///
///
///
///
///
///
public Contract AreNotEquals(double val, int comparer, string key, string message) =>
AreNotEquals(val, (double)comparer, key, message);
///
/// Requires two decimals are not equals
///
///
///
///
///
public Contract AreNotEquals(double val, float comparer, string key) =>
AreNotEquals(val, (double)comparer, key, FluntErrorMessages.AreNotEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are not equals
///
///
///
///
///
///
public Contract AreNotEquals(double val, float comparer, string key, string message) =>
AreNotEquals(val, (double)comparer, key, message);
///
/// Requires two decimals are not equals
///
///
///
///
///
public Contract AreNotEquals(double val, decimal comparer, string key) =>
AreNotEquals(val, (double)comparer, key, FluntErrorMessages.AreNotEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are not equals
///
///
///
///
///
///
public Contract AreNotEquals(double val, decimal comparer, string key, string message) =>
AreNotEquals(val, (double)comparer, key, message);
///
/// Requires two decimals are not equals
///
///
///
///
///
public Contract AreNotEquals(double val, long comparer, string key) =>
AreNotEquals(val, (double)comparer, key, FluntErrorMessages.AreNotEqualsErrorMessage(val.ToString(), comparer.ToString()));
///
/// Requires two decimals are not equals
///
///
///
///
///
///
public Contract AreNotEquals(double val, long comparer, string key, string message) =>
AreNotEquals(val, (double)comparer, key, message);
#endregion
#region IsNull
///
/// Requires a double is null
///
///
///
///
public Contract IsNull(double? val, string key) =>
IsNull(val, key, FluntErrorMessages.IsNullErrorMessage(key));
///
/// Requires a double is null
///
///
///
///
///
public Contract IsNull(double? val, string key, string message)
{
if (val != null)
AddNotification(key, message);
return this;
}
#endregion
#region IsNotNull
///
/// Requires a double is not null
///
///
///
///
public Contract IsNotNull(double? val, string key) =>
IsNotNull(val, key, FluntErrorMessages.IsNotNullErrorMessage(key));
///
/// Requires a double is not null
///
///
///
///
///
public Contract IsNotNull(double? val, string key, string message)
{
if (val == null)
AddNotification(key, message);
return this;
}
#endregion
#region IsBetween
///
/// Requires a double is between
///
///
///
///
///
///
public Contract IsBetween(double val, double start, double end, string key) =>
IsBetween(val, start, end, key, FluntErrorMessages.IsBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a double is between
///
///
///
///
///
///
///
public Contract IsBetween(double val, double start, double end, string key, string message)
{
if ((val >= start && val <= end) == false)
AddNotification(key, message);
return this;
}
///
/// Requires a double is between
///
///
///
///
///
///
public Contract IsBetween(double val, int start, int end, string key) =>
IsBetween(val, (double)start, (double)end, key, FluntErrorMessages.IsBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a double is between
///
///
///
///
///
///
///
public Contract IsBetween(double val, int start, int end, string key, string message) =>
IsBetween(val, (double)start, (double)end, key, message);
///
/// Requires a double is between
///
///
///
///
///
///
public Contract IsBetween(double val, float start, float end, string key) =>
IsBetween(val, (double)start, (double)end, key, FluntErrorMessages.IsBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a double is between
///
///
///
///
///
///
///
public Contract IsBetween(double val, float start, float end, string key, string message) =>
IsBetween(val, (double)start, (double)end, key, message);
///
/// Requires a double is between
///
///
///
///
///
///
public Contract IsBetween(double val, decimal start, decimal end, string key) =>
IsBetween(val, (double)start, (double)end, key, FluntErrorMessages.IsBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a double is between
///
///
///
///
///
///
///
public Contract IsBetween(double val, decimal start, decimal end, string key, string message) =>
IsBetween(val, (double)start, (double)end, key, message);
///
/// Requires a double is between
///
///
///
///
///
///
public Contract IsBetween(double val, long start, long end, string key) =>
IsBetween(val, (double)start, (double)end, key, FluntErrorMessages.IsBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a double is between
///
///
///
///
///
///
///
public Contract IsBetween(double val, long start, long end, string key, string message) =>
IsBetween(val, (double)start, (double)end, key, message);
#endregion
#region IsNotBetween
///
/// Requires a double is not between
///
///
///
///
///
///
public Contract IsNotBetween(double val, double start, double end, string key) =>
IsNotBetween(val, start, end, key, FluntErrorMessages.IsNotBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///
/// Requires a double is not between
///
///
///
///
///
///
///
public Contract IsNotBetween(double val, double start, double end, string key, string message)
{
if ((val >= start && val <= end) == true)
AddNotification(key, message);
return this;
}
///
/// Requires a double is not between
///
///
///
///
///
///
public Contract IsNotBetween(double val, int start, int end, string key) =>
IsNotBetween(val, (double)start, (double)end, key, FluntErrorMessages.IsNotBetweenErrorMessage(key, start.ToString(FluntFormats.DateTimeFormat), end.ToString(FluntFormats.DateTimeFormat)));
///