magic.lambda.validators 14.0.10

There is a newer version of this package available.
See the version list below for details.
dotnet add package magic.lambda.validators --version 14.0.10                
NuGet\Install-Package magic.lambda.validators -Version 14.0.10                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="magic.lambda.validators" Version="14.0.10" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.lambda.validators --version 14.0.10                
#r "nuget: magic.lambda.validators, 14.0.10"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install magic.lambda.validators as a Cake Addin
#addin nuget:?package=magic.lambda.validators&version=14.0.10

// Install magic.lambda.validators as a Cake Tool
#tool nuget:?package=magic.lambda.validators&version=14.0.10                

Validating input arguments from Hyperlambda

This project contains input validators for Magic. More specifically it contains the following slots.

  • [validators.date] - Verifies that some date input is a date, and optionally between [min] and [max] value
  • [validators.email] - Verifies that some input is a legal email address
  • [validators.enum] - Verifies that some input is one of a set of predefined legal values, found as values of children
  • [validators.integer] - Verifies that some integer input (long, int, etc) is between some specified [min] and [max] range
  • [validators.mandatory] - Verifies that some input valus is given (at all)
  • [validators.regex] - Verifies that some input is matching some given [regex] pattern
  • [validators.string] - Verifies that some string input is between [min] and [max] in length
  • [validators.url] - Verifies that some string input is a legal URL, either HTTP or HTTPS type of scheme
  • [validators.recaptcha] - reCAPTCHA validator, to avoid bots from invoking your APIs

All of the above slots takes an expression, or values, as its main input, and will throw exceptions if their input expression's value(s), or its value, does not follow the rules specified by the validator. This makes them perfect fits for "intercepting" the input specified to an HTTP REST endpoint, to verify the input data conforms to some sort of predefined validation scheme.

Usage

.foo
   number:int:11

validators.integer:x:@.foo/*/number
   min:int:5
   max:int:10

Most validators requires some sort of argument(s), such as you can see above in the integer validator - However, some of these validators are without arguments, such as the email validator, that simply verifies the input is a valid email address. To use the [validators.regex] validator, you should probably learn regular expression. However, this is beyond the scope of this article.

Notice - No attempt to invoke the type validator logic will be done unless the value is a non null value. If you want to enforce such logic, you'll have to combine the specific type validators with the [validators.mandatory] validator, which enforces that a value must be specified and be non null.

Internals

You can use one invocation to any of the validators to validate multiple nodes, such as the following illustrates.

.arguments
   .
      no:5
   .
      no:10
   .
      // Throws if you remove the "."
      .no:11

validators.integer:x:@.arguments/*/*/no
   min:5
   max:10

First the above expression will be evaluated, then every resulting value will be validated, and if any of them are not validated according to the validtor's arguments - Which for the above example is number between 5 and 10 - The validater will throw an exception, providing the invalid value, and the name of the last iterator (effectively being the argument name) to the caller. This allows you to use one single validator to validate multiple arguments, such as the above illustrates. This might be useful if you for instance have an endpoint accepting multiple address fields, and zip code is a mandatory argument, and it needs to be an integer with a [max] and [min] value.

Project website

The source code for this repository can be found at github.com/polterguy/magic.lambda.validators, and you can provide feedback, provide bug reports, etc at the same place.

Quality gates

  • Build status
  • Quality Gate Status
  • Bugs
  • Code Smells
  • Coverage
  • Duplicated Lines (%)
  • Lines of Code
  • Maintainability Rating
  • Reliability Rating
  • Security Rating
  • Technical Debt
  • Vulnerabilities
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on magic.lambda.validators:

Package Downloads
magic.library

Helper project for Magic to wire up everything easily by simply adding one package, and invoking two simple methods. When using Magic, this is (probably) the only package you should actually add, since this package pulls in everything else you'll need automatically, and wires up everything sanely by default. To use package go to https://polterguy.github.io

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
17.2.0 444 1/22/2024
17.1.7 191 1/12/2024
17.1.6 172 1/11/2024
17.1.5 187 1/5/2024
17.0.1 237 1/1/2024
17.0.0 382 12/14/2023
16.11.5 348 11/12/2023
16.9.0 334 10/9/2023
16.7.0 577 7/11/2023
16.4.1 418 7/2/2023
16.4.0 417 6/22/2023
16.3.1 346 6/7/2023
16.3.0 362 5/28/2023
16.1.9 640 4/30/2023
15.10.11 510 4/13/2023
15.9.1 650 3/27/2023
15.9.0 518 3/24/2023
15.8.2 547 3/20/2023
15.7.0 422 3/6/2023
15.5.0 1,600 1/28/2023
15.2.0 701 1/18/2023
15.1.0 1,162 12/28/2022
14.5.7 738 12/13/2022
14.5.5 801 12/6/2022
14.5.1 677 11/23/2022
14.5.0 611 11/18/2022
14.4.5 724 10/22/2022
14.4.1 795 10/22/2022
14.4.0 683 10/17/2022
14.3.1 1,279 9/12/2022
14.3.0 638 9/10/2022
14.1.3 937 8/7/2022
14.1.2 662 8/7/2022
14.1.1 678 8/7/2022
14.0.14 707 7/26/2022
14.0.12 684 7/24/2022
14.0.11 647 7/23/2022
14.0.10 679 7/23/2022
14.0.9 668 7/23/2022
14.0.8 761 7/17/2022
14.0.5 798 7/11/2022
14.0.4 781 7/6/2022
14.0.3 740 7/2/2022
14.0.2 692 7/2/2022
14.0.0 858 6/25/2022
13.4.0 2,076 5/31/2022
13.3.4 1,461 5/9/2022
13.3.0 966 5/1/2022
13.2.0 1,171 4/21/2022
13.1.1 750 4/20/2022
13.1.0 825 4/7/2022
13.0.0 761 4/5/2022
11.0.5 1,431 3/2/2022
11.0.4 791 2/22/2022
11.0.3 763 2/9/2022
11.0.2 841 2/6/2022
11.0.1 789 2/5/2022
10.0.21 767 1/28/2022
10.0.20 785 1/27/2022
10.0.19 772 1/23/2022
10.0.18 745 1/17/2022
10.0.15 944 12/31/2021
10.0.14 585 12/28/2021
10.0.7 1,471 12/22/2021
10.0.5 766 12/18/2021
9.9.9 1,686 11/29/2021
9.9.3 946 11/9/2021
9.9.2 670 11/4/2021
9.9.0 762 10/30/2021
9.8.9 703 10/29/2021
9.8.7 660 10/27/2021
9.8.6 656 10/27/2021
9.8.5 722 10/26/2021
9.8.0 1,379 10/20/2021
9.7.9 648 10/19/2021
9.7.5 1,486 10/14/2021
9.7.0 860 10/9/2021
9.6.6 1,230 8/14/2021
9.2.0 393 5/26/2021
9.1.7 6,932 5/3/2021
9.1.4 681 4/21/2021
9.1.0 1,061 4/14/2021
9.0.0 917 4/5/2021
8.9.9 1,016 3/30/2021
8.9.3 1,569 3/19/2021
8.9.2 1,025 1/29/2021
8.9.1 1,025 1/24/2021
8.9.0 1,087 1/22/2021
8.6.9 2,993 11/8/2020
8.6.6 1,968 11/2/2020
8.6.0 4,046 10/28/2020
8.5.0 1,918 10/23/2020
8.4.1 4,869 10/15/2020
8.4.0 1,324 10/13/2020
8.3.1 2,675 10/5/2020
8.3.0 1,263 10/3/2020
8.2.2 2,037 9/26/2020
8.2.1 1,343 9/25/2020
8.2.0 1,397 9/25/2020
8.1.17 6,783 9/13/2020
8.1.16 641 9/13/2020
8.1.15 1,932 9/12/2020
8.1.11 2,525 9/11/2020
8.1.10 1,311 9/6/2020
8.1.9 1,341 9/3/2020
8.1.8 1,306 9/2/2020
8.1.7 1,214 8/28/2020
8.1.4 1,235 8/25/2020
8.1.3 1,262 8/18/2020
8.1.2 1,232 8/16/2020
8.1.1 1,277 8/15/2020
8.1.0 588 8/15/2020
8.0.1 2,685 8/7/2020
8.0.0 1,237 8/7/2020
7.0.1 1,384 6/28/2020
7.0.0 1,378 6/28/2020
5.0.0 7,496 2/25/2020
4.0.4 7,997 1/27/2020
4.0.3 1,250 1/27/2020
4.0.2 1,423 1/16/2020
4.0.1 1,416 1/11/2020
4.0.0 1,349 1/5/2020
3.1.1 4,221 12/4/2019
3.1.0 2,780 11/10/2019
3.0.0 3,927 10/23/2019
2.0.0 6,643 10/18/2019