magic.lambda.validators
16.7.0
See the version list below for details.
dotnet add package magic.lambda.validators --version 16.7.0
NuGet\Install-Package magic.lambda.validators -Version 16.7.0
<PackageReference Include="magic.lambda.validators" Version="16.7.0" />
paket add magic.lambda.validators --version 16.7.0
#r "nuget: magic.lambda.validators, 16.7.0"
// Install magic.lambda.validators as a Cake Addin #addin nuget:?package=magic.lambda.validators&version=16.7.0 // Install magic.lambda.validators as a Cake Tool #tool nuget:?package=magic.lambda.validators&version=16.7.0
magic.lambda.validators - Hyperlambda validators
This project contains argument validators for Hyperlambda. 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
- [validators.default] - Default validator, adding default argument if not specified
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. Some of the above slots takes additional arguments. 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.
Commonalities between validators
.foo
email:foo@bar.com
validators.email:x:@.foo/*/email
Most Hyperlambda validators requires some sort of argument(s) - However, some of these validators does not require 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, that enforces that a value must be specified and not have a null value.
How to use [validators.date]
This slot works similarly to the [validator.integer] validator, except instead of providing a min/max integer value, you're expected to provide a min/max date value. Below is an example of how you could use it.
validators.date:x:@.arguments/*/date
min:date:"2005-01-21T23:59:47"
max:date:"2023-01-21T23:59:47"
How to use [validators.email]
This slot takes no arguments besides an expression, and will throw an exception unless the value of the node the expression is leading to is a valid email address. Below is example usage.
.arg:foo@bar.com
validators.email:x:@.arg
How to use [validators.enum]
This validator will throw an exception unless the specified string argument is one of the legal values. Usage could be as follows.
validators.enum:x:@.arguments/*/enum_value
.:val1
.:val2
If the above [enum_value] is not either val1
or val2
the validator will throw an exception.
How to use [validators.integer]
This value takes a [min] and [max] value, both of which are optional, and declares the minimum, and/or maximum value of the integer input. Usage could be as follows.
validators.integer:x:@.arguments/*/some-integer-argument
min:50
max:100
If the specified integer value is not within the range of the min and max value, an exception will be thrown.
How to use [validators.mandatory]
This slot simply throws an exception if the specified argument is not supplied. Below is example usage.
validators.mandatory:x:@.arguments/*/mandatory_arg
How to use [validators.regex]
This validator requires a [regex] argument, that is a regular expression that must match the argument specified. Usage can be found below.
.arguments
foo:howdy world
validators.regex:x:@.arguments/*/foo
regex:howdy
If you remove the "howdy" parts of your above argument, an exception will be thrown.
How to use [validators.string]
This works the same way as the [validators.integer] validator, except instead of being a min/max value the min/max arguments declares the minimum and maximum length of the string, allowing you to restrict string length of arguments to a min/max value for your Hyperlambda. Below is example usage that will throw an exception unless the argument is between 5 and 15 characters in length.
validators.string:x:@.some-arg
min:5
max:15
How to use [validators.url]
This is similar to the [validators.email] slot, except it requires the argument to be a valid URL instead of a valid email. Below is example usage.
validators.url:x:@.some-url
How to use [validators.recaptcha]
This is probably the most complex validator, and required 3 arguments.
- [site-key] - Site key as provided to you by Google's reCAPTCHA admin panel
- [secret] - Secret as provided to you by Google's reCAPTCHA admin panel
- [min] - Minimum value, a decimal value between 0 and 1. A good value here is typically 0.3
To use this validator you will need a Google reCAPTCHA account, version 3, at which point you can use it as follows.
validators.recaptcha:x:@.arguments/*/recaptcha_value
site-key:xyz
secret:qwerty
min:decimal:0.3
How to use [validators.default]
This validator takes one or more arguments with any name and any value, and if this node does not exist as a child of the node collection specified as its expression value, it appends the node to it. If the node exists but has a null value, it sets its value to the value of the argument.
.arguments
validators.default:x:@.arguments
foo1:bar1
Validator 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 validator'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 for magic.lambda.validators
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.
Copyright and maintenance
The projects is copyright of Aista, Ltd 2021 - 2023, and professionally maintained by AINIRO your friendly ChatGPT website chatbot vendor.
Product | Versions 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. |
-
.NETStandard 2.0
- magic.node.extensions (>= 16.7.0)
- magic.signals.contracts (>= 16.7.0)
- Newtonsoft.Json (>= 13.0.1)
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 | 433 | 1/22/2024 |
17.1.7 | 186 | 1/12/2024 |
17.1.6 | 167 | 1/11/2024 |
17.1.5 | 180 | 1/5/2024 |
17.0.1 | 232 | 1/1/2024 |
17.0.0 | 377 | 12/14/2023 |
16.11.5 | 341 | 11/12/2023 |
16.9.0 | 329 | 10/9/2023 |
16.7.0 | 572 | 7/11/2023 |
16.4.1 | 413 | 7/2/2023 |
16.4.0 | 413 | 6/22/2023 |
16.3.1 | 342 | 6/7/2023 |
16.3.0 | 358 | 5/28/2023 |
16.1.9 | 636 | 4/30/2023 |
15.10.11 | 506 | 4/13/2023 |
15.9.1 | 646 | 3/27/2023 |
15.9.0 | 514 | 3/24/2023 |
15.8.2 | 543 | 3/20/2023 |
15.7.0 | 418 | 3/6/2023 |
15.5.0 | 1,596 | 1/28/2023 |
15.2.0 | 697 | 1/18/2023 |
15.1.0 | 1,158 | 12/28/2022 |
14.5.7 | 734 | 12/13/2022 |
14.5.5 | 795 | 12/6/2022 |
14.5.1 | 673 | 11/23/2022 |
14.5.0 | 607 | 11/18/2022 |
14.4.5 | 720 | 10/22/2022 |
14.4.1 | 791 | 10/22/2022 |
14.4.0 | 679 | 10/17/2022 |
14.3.1 | 1,275 | 9/12/2022 |
14.3.0 | 634 | 9/10/2022 |
14.1.3 | 933 | 8/7/2022 |
14.1.2 | 658 | 8/7/2022 |
14.1.1 | 674 | 8/7/2022 |
14.0.14 | 703 | 7/26/2022 |
14.0.12 | 680 | 7/24/2022 |
14.0.11 | 643 | 7/23/2022 |
14.0.10 | 675 | 7/23/2022 |
14.0.9 | 664 | 7/23/2022 |
14.0.8 | 755 | 7/17/2022 |
14.0.5 | 794 | 7/11/2022 |
14.0.4 | 777 | 7/6/2022 |
14.0.3 | 736 | 7/2/2022 |
14.0.2 | 688 | 7/2/2022 |
14.0.0 | 854 | 6/25/2022 |
13.4.0 | 2,072 | 5/31/2022 |
13.3.4 | 1,457 | 5/9/2022 |
13.3.0 | 962 | 5/1/2022 |
13.2.0 | 1,167 | 4/21/2022 |
13.1.1 | 746 | 4/20/2022 |
13.1.0 | 821 | 4/7/2022 |
13.0.0 | 757 | 4/5/2022 |
11.0.5 | 1,427 | 3/2/2022 |
11.0.4 | 787 | 2/22/2022 |
11.0.3 | 759 | 2/9/2022 |
11.0.2 | 835 | 2/6/2022 |
11.0.1 | 785 | 2/5/2022 |
10.0.21 | 763 | 1/28/2022 |
10.0.20 | 781 | 1/27/2022 |
10.0.19 | 768 | 1/23/2022 |
10.0.18 | 737 | 1/17/2022 |
10.0.15 | 940 | 12/31/2021 |
10.0.14 | 579 | 12/28/2021 |
10.0.7 | 1,465 | 12/22/2021 |
10.0.5 | 762 | 12/18/2021 |
9.9.9 | 1,682 | 11/29/2021 |
9.9.3 | 942 | 11/9/2021 |
9.9.2 | 666 | 11/4/2021 |
9.9.0 | 758 | 10/30/2021 |
9.8.9 | 699 | 10/29/2021 |
9.8.7 | 656 | 10/27/2021 |
9.8.6 | 652 | 10/27/2021 |
9.8.5 | 716 | 10/26/2021 |
9.8.0 | 1,375 | 10/20/2021 |
9.7.9 | 644 | 10/19/2021 |
9.7.5 | 1,482 | 10/14/2021 |
9.7.0 | 856 | 10/9/2021 |
9.6.6 | 1,226 | 8/14/2021 |
9.2.0 | 389 | 5/26/2021 |
9.1.7 | 6,928 | 5/3/2021 |
9.1.4 | 677 | 4/21/2021 |
9.1.0 | 1,057 | 4/14/2021 |
9.0.0 | 913 | 4/5/2021 |
8.9.9 | 1,012 | 3/30/2021 |
8.9.3 | 1,565 | 3/19/2021 |
8.9.2 | 1,019 | 1/29/2021 |
8.9.1 | 1,019 | 1/24/2021 |
8.9.0 | 1,081 | 1/22/2021 |
8.6.9 | 2,987 | 11/8/2020 |
8.6.6 | 1,962 | 11/2/2020 |
8.6.0 | 4,040 | 10/28/2020 |
8.5.0 | 1,912 | 10/23/2020 |
8.4.1 | 4,863 | 10/15/2020 |
8.4.0 | 1,318 | 10/13/2020 |
8.3.1 | 2,669 | 10/5/2020 |
8.3.0 | 1,257 | 10/3/2020 |
8.2.2 | 2,031 | 9/26/2020 |
8.2.1 | 1,337 | 9/25/2020 |
8.2.0 | 1,391 | 9/25/2020 |
8.1.17 | 6,777 | 9/13/2020 |
8.1.16 | 635 | 9/13/2020 |
8.1.15 | 1,926 | 9/12/2020 |
8.1.11 | 2,519 | 9/11/2020 |
8.1.10 | 1,305 | 9/6/2020 |
8.1.9 | 1,335 | 9/3/2020 |
8.1.8 | 1,300 | 9/2/2020 |
8.1.7 | 1,208 | 8/28/2020 |
8.1.4 | 1,229 | 8/25/2020 |
8.1.3 | 1,256 | 8/18/2020 |
8.1.2 | 1,226 | 8/16/2020 |
8.1.1 | 1,271 | 8/15/2020 |
8.1.0 | 580 | 8/15/2020 |
8.0.1 | 2,679 | 8/7/2020 |
8.0.0 | 1,231 | 8/7/2020 |
7.0.1 | 1,378 | 6/28/2020 |
7.0.0 | 1,372 | 6/28/2020 |
5.0.0 | 7,490 | 2/25/2020 |
4.0.4 | 7,991 | 1/27/2020 |
4.0.3 | 1,244 | 1/27/2020 |
4.0.2 | 1,417 | 1/16/2020 |
4.0.1 | 1,410 | 1/11/2020 |
4.0.0 | 1,343 | 1/5/2020 |
3.1.1 | 4,215 | 12/4/2019 |
3.1.0 | 2,774 | 11/10/2019 |
3.0.0 | 3,921 | 10/23/2019 |
2.0.0 | 6,637 | 10/18/2019 |