HotChoco.ArgumentValidator 1.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package HotChoco.ArgumentValidator --version 1.0.0
NuGet\Install-Package HotChoco.ArgumentValidator -Version 1.0.0
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="HotChoco.ArgumentValidator" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HotChoco.ArgumentValidator --version 1.0.0
#r "nuget: HotChoco.ArgumentValidator, 1.0.0"
#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 HotChoco.ArgumentValidator as a Cake Addin
#addin nuget:?package=HotChoco.ArgumentValidator&version=1.0.0

// Install HotChoco.ArgumentValidator as a Cake Tool
#tool nuget:?package=HotChoco.ArgumentValidator&version=1.0.0

Adds support for validating input arguments in HotChocolate

Generally we use attributes from System.Annotations for validating our input models in controllers.

As HotChocolate don't validate input arguments , After installing this pacakage, By just adding 2 lines of code in your Startup.cs file. You will be adding support for validation to all input models in your Queries/Mutations.

Steps for configuring validator

Step 1

Go to StartUp.cs file and inside ConfigureServices make the following changes.

Step 2

Keep this code to validate all inputs of GraphQL Query/Mutation.

ValidatorSettings.ValdiateAllInputs = true;

Step 3

Add argument valdiator to services by referring below code

services
  .AddGraphQLServer()
  .AddArgumentValidator();

Additional Configuration

If you don't want to valdiate all inputs then you can skip step 2 and follow the optional step i.e

Just add Validatable attribute to the class u defined for input.

Ex:

    [Validatable]
    public class AddUserInput
    {
        [Required, MinLength(4, ErrorMessage = "Username must be atleast 4 characters.")]
        public string UserName { get; set; }

        [Required, RegularExpression(@"^[^@\s]+@[^@\s]+\.[^@\s]+$", ErrorMessage = "Email Id format is invalid")]
        public string Email { get; set; }

        [Required, RegularExpression(@"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$", ErrorMessage = "Password needs to be more strong.")]
        public string Password { get; set; }
    }

When user given wrong values to input, this is how the response from GraphQL Server will looks like

{
  "errors": [
    {
      "message": "Username must be at least 4 characters."
    },
    {
      "message": "Password needs to be more strong."
    }
  ]
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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 is compatible. 
.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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated