RioClassLibrary 1.0.2
dotnet add package RioClassLibrary --version 1.0.2
NuGet\Install-Package RioClassLibrary -Version 1.0.2
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="RioClassLibrary" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RioClassLibrary --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RioClassLibrary, 1.0.2"
#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 RioClassLibrary as a Cake Addin #addin nuget:?package=RioClassLibrary&version=1.0.2 // Install RioClassLibrary as a Cake Tool #tool nuget:?package=RioClassLibrary&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
JSON Validator
public void Run () {
var json = "{'Id':1,'Name': 'Test','Payload':'12, 323, 232'}";
#if DEBUG
Console.WriteLine($"Validating the following json: {json}");
#endif
// create a new instance of 'JsonValidator'
// the primary constructor takes a 'HashSet<IJsonValidationStrategy>'
// simply pass an instance(s) to the constructor containing concrete
// implementations of 'IJsonValidationStrategy'
// the default constructor takes a hashset for process strategies and preprocess strategies (optional)
var validator = new JsonValidator(
[new ValidateIsJsonObject()],
[new ValidateNoApostrophe()]);
// invoke the 'Validate' method
var result = validator.Validate(ref json);
// check if there were errors
var hadErrors = result.HadErrors;
// if hadErrors is true, we can query a dictionary (nullable) of error strings
var errors = result.Errors;
// if 'result.HadErrors' is false, then 'result.Errors' will be null
// the new validated string will be return if 'result.HadErrors' is false
// otherwise, 'result.Json' will be 'string.Empty'
var validatedJson = result.Json;
#if DEBUG
Console.WriteLine($"Validation resulted in the following json: {validatedJson}");
#endif
/// <summary>
/// To create your own validation strategies, create a new class and implement 'IJsonValidationStrategy'
/// The method to define implementation for is 'ValidateStrategy(System.Span<byte> json)'
/// Take note -> this span is mutable; you are directly modifying the byte values for a contiguous
/// portion of memory allocated on the stack
/// </summary>
public class MyJsonValidationExample : IJsonValidationStrategy
{
public JsonStrategyResult ValidateStrategy(System.Span<byte> json)
{
throw new NotImplementedException();
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Modified JsonValidationResult to accept an appropriate collection for 'Errors'.