valgo

package module
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 10 Imported by: 0

README

Valgo

Valgo is a type-safe, expressive, and extensible validator library for Golang. Valgo is built with generics, so Go 1.18 or higher is required.

Valgo differs from other Golang validation libraries in that the rules are written in functions and not in struct tags. This allows greater flexibility and freedom when it comes to where and how data is validated.

Additionally, Valgo supports customizing and localizing validation messages.

Quick example

Here is a quick example:

package main

import v "github.com/cohesivestack/valgo"

func main() {
  val := v.
    Is(v.String("Bob", "full_name").Not().Blank().OfLengthBetween(4, 20)).
    Is(v.Number(17, "age").GreaterThan(18))

  if !val.Valid() {
    out, _ := json.MarshalIndent(val.Error(), "", "  ")
    fmt.Println(string(out))
  }
}

output:

{
  "age": [
    "Age must be greater than \"18\""
  ],
  "full_name": [
    "Full name must have a length between \"4\" and \"20\""
  ]
}

v0.x.x and backward compatibility

Valgo is in its early stages, so backward compatibility won't be guaranteed until v1.

Valgo is used in production by Statsignal, but we want community feedback before releasing version 1.

Table of content

Getting started

Install in your project:

go get github.com/cohesivestack/valgo

Import in your code:

import v github.com/cohesivestack/valgo

Note: You can use any other aliases instead of v or just reference the package valgo directly.

Using Valgo

Validation session

The Validation session in Valgo is the main structure for validating one or more values. It is called 'Validation' in code.

A validation session will contain one or more Validators, where each Validator will have the responsibility to validate a value with one or more rules.

There are multiple functions to create a Validation session, depending on the requirements:

  • New(),
  • Is(...),
  • In(...),
  • InRow(...),
  • Check(...),
  • AddErrorMessage(...)

Is(...) is likely to be the most frequently used function in your validations. When Is(...) is called, the function creates a validation and receives a validator at the same time. In the next section, you will learn more about the Is(...) function.

Is(...) function

The Is(...) function allows you to pass a Validator with the value and the rules for validating it. At the same time, create a Validation session, which lets you add more Validators in order to verify more values.

As shown in the following example, we are passing to the function Is(...) the Validator for the full_name value. The function returns a Validation session that allows us to add more Validators to validate more values; in the example case the values age and status:

val := v.
  Is(v.String("Bob", "full_name").Not().Blank().OfLengthBetween(4, 20)).
  Is(v.Number(17, "age").GreaterThan(18)).
  Is(v.String("singl", "status").InSlice([]string{"married", "single"}))

if !val.Valid() {
  out, _ := json.MarshalIndent(val.Error(), "", "  ")
  fmt.Println(string(out))
}

output:

{
  "age": [
    "Age must be greater than \"18\""
  ],
  "full_name": [
    "Full name must have a length between \"4\" and \"20\""
  ],
  "status": [
    "Status is not valid"
  ]
}

Validation.Valid() function

A Validation session provide this function, which returns either true if all their validators are valid or false if any one of them is invalid.

In the following example, even though the Validator for age is valid, the Validator for status is invalid, making the entire Validator session invalid.

val := v.Is(v.Number(21, "age").GreaterThan(18)).
  Is(v.String("singl", "status").InSlice([]string{"married", "single"}))

if !val.Valid() {
  out, _ := json.MarshalIndent(val.Error(), "", "  ")
  fmt.Println(string(out))
}

output:

{
  "status": [
    "Status is not valid"
  ]
}

Validation.IsValid(...) function

This functions allows to check if an specific value in a Validation session is valid or not. This is very useful for conditional logic.

The following example prints an error message if the age value is invalid.

val := v.Is(v.Number(16, "age").GreaterThan(18)).
  Is(v.String("single", "status").InSlice([]string{"married", "single"}))

if !val.IsValid("age") {
  fmt.Println("Warning: someone underage is trying to sign up")
}

output:

Warning: someone underage is trying to sign up

In(...) function

The In(...) function executes one or more validators in a namespace, so the value names in the error result are prefixed with this namespace. This is useful for validating nested structures.

In the following example we are validating the Person and the nested Address structure. We can distinguish the errors of the nested Address structure in the error results.

type Address struct {
  Name string
  Street string
}

type Person struct {
  Name string
  Address Address
}

p := Person{"Bob", Address{"", "1600 Amphitheatre Pkwy"}}

val := v.
  Is(v.String(p.Name, "name").OfLengthBetween(4, 20)).
  In("address",
    Is(String(p.Address.Name, "name").Not().Blank()).
    Is(String(p.Address.Street, "street").Not().Blank()))

if !val.Valid() {
  out, _ := json.MarshalIndent(val.Error(), "", "  ")
  fmt.Println(string(out))
}

output:

{
  "address.name": [
    "Name can't be blank"
  ],
  "name": [
    "Name must have a length between \"4\" and \"20\""
  ]
}

InRow(...) function

The InRow(...) function executes one or more validators in a namespace similar to the In(...) function, but with indexed namespace. So, the value names in the error result are prefixed with this indexed namespace. It is useful for validating nested lists in structures.

In the following example we validate the Person and the nested list Addresses. The error results can distinguish the errors of the nested list Addresses.

type Address struct {
  Name   string
  Street string
}

type Person struct {
  Name      string
  Addresses []Address
}

p := Person{
  "Bob",
  []Address{
    {"", "1600 Amphitheatre Pkwy"},
    {"Home", ""},
  },
}

val := v.Is(String(p.Name, "name").OfLengthBetween(4, 20))

for i, a := range p.Addresses {
  val.InRow("addresses", i,
    v.Is(v.String(a.Name, "name").Not().Blank()).
    v.Is(v.String(a.Street, "street").Not().Blank()))
}

if !val.Valid() {
  out, _ := json.MarshalIndent(val.Error(), "", "  ")
  fmt.Println(string(out))
}

output:

{
  "addresses[0].name": [
    "Name can't be blank"
  ],
  "addresses[1].street": [
    "Street can't be blank"
  ],
  "name": [
    "Name must have a length between \"4\" and \"20\""
  ]
}

Check(...) function

The Check(...) function, similar to the Is(...) function, however with Check(...) the Rules of the Validator parameter are not short-circuited, which means that regardless of whether a previous rule was valid, all rules are checked.

This example shows two rules that fail due to the empty value in the full_name Validator, and since the Validator is not short-circuited, both error messages are added to the error result.

val := v.Check(v.String("", "full_name").Not().Blank().OfLengthBetween(4, 20))

if !val.Valid() {
  out, _ := json.MarshalIndent(val.Error(), "", "  ")
  fmt.Println(string(out))
}

output:

{
  "full_name": [
    "Full name can't be blank",
	  "Full name must have a length between \"4\" and \"20\""
  ]
}

AddErrorMessage(...) function

The AddErrorMessage function allows to add an error message to a Validation session without executing a field validator. This function takes in two arguments: name, which is the name of the field for which the error message is being added, and message, which is the error message being added to the session.

When an error message is added using this function, the Validation session is marked as invalid, indicating that at least one validation error has occurred.

One use case for the AddErrorMessage function is to add a general error message for the validation of an entity structure. As shown in the example below, if you have an entity structure for an address and need to validate multiple fields within it, such as the city and street, you can use AddErrorMessage to include a general error message for the entire address in case any of the fields fail validation.

type Address struct {
  City string
  Street string
}

a := Address{"", "1600 Amphitheatre Pkwy"}

val := v.
  Is(String(a.city, "city").Not().Blank()).
  Is(String(a.Street, "street").Not().Blank())

if !val.Valid() {
  v.AddErrorMessage("address", "The address is wrong!")

  out, _ := json.MarshalIndent(val.Error(), "", "  ")
  fmt.Println(string(out))
}

output:

{
  "address": [
    "The address is wrong!"
  ],
  "city": [
    "City can't be blank"
  ]
}

It's worth noting that there may be other use cases for this function as well.

Merging two Validation sessions with Validation.Merge( ... )

Using Merge(...) you can merge two Validation sessions. When two validations are merged, errors with the same value name will be merged. It is useful for reusing validation logic.

The following example merges the Validation session returned by the validatePreStatus function. Since both Validation sessions validate a value with the name status, the error returned will return two error messages, and without duplicate the Not().Blank() error message rule.


type Record struct {
  Name   string
  Status string
}

validatePreStatus := func(status string) *Validation {
  regex, _ := regexp.Compile("pre-.+")

  return v.
    Is(v.String(status, "status").Not().Blank().MatchingTo(regex))
}

r := Record{"Classified", ""}

val := v.
  Is(v.String(r.Name, "name").Not().Blank()).
  Is(v.String(r.Status, "status").Not().Blank())

val.Merge(validatePreStatus(r.Status))

if !val.Valid() {
  out, _ := json.MarshalIndent(val.Error(), "", "  ")
  fmt.Println(string(out))
}

output:

{
  "status": [
	  "Status can't be blank",
	  "Status must match to \"pre-.+\""
  ]
}

New() function

This function allows you to create a new Validation session without a Validator. This is useful for conditional validation or reusing validation logic.

The function accepts an optional parameter of type [Options] struct, which allows you to specify options such as the specific locale code and locale to use, and a custom JSON marshaler for errors.

The following example conditionally adds a Validator rule for the month_day value.

month := 5
monthDay := 11

val := v.New()

if month == 6 {
  val.Is(v.Number(monthDay, "month_day").LessOrEqualTo(10))
}

if val.Valid() {
  fmt.Println("The validation passes")
}

output:

The validation passes

As we mentioned above, you can pass the Options type to the New() function, in order to specify additional options when creating a new Validation session, such as the specific locale code and locale to use, and a custom JSON marshaler for errors. More information about the Options parameter in the following sections.

Custom error message template

Customizing the default Valgo error messages is possible through the New() function as it's explained in the Localizing a validation session with New section, however the Valgo validators allow to customize the template of a specific template validator rule. Below is an example illustrating this with the String empty validator rule.

val := v.Is(v.String("", "address_field", "Address").Not().Empty("{{title}} must not be empty. Please provide the value in the input {{name}}."))

out, _ := json.MarshalIndent(val.Error(), "", "  ")
fmt.Println(string(out))

output:

{
  "address": [
         "Address must not be empty. Please provide the value in the input address_field."
  ]
}

Localizing a validation session with New(...options) function

Valgo has localized error messages. The error messages are currently available in English (default), Spanish and German. However, it is possible to set error messages for any locale by passing the Options parameter to the New() function. Using this parameter, you can also customize the existing Valgo locale messages.

There are two options for localization: localeCode and locale. Below, we list the different ways to customize localization with these two parameters.

  • Changing the validation session's locale In the following example, we are setting the Spanish locale:

    // Creating the new validation session with other locale
    val := v.New(v.Options{ LocaleCode: "es" })
    
    // Testing the output
    val := val.Check(v.String(" ", "nombre").Not().Blank())
    
    out, _ := json.MarshalIndent(val.Error(), "", "  ")
    fmt.Println(string(out))
    

    output:

    {
      "name": [
        "Nombre no puede estar en blanco"
      ]
    }
    

    If the specified locale does not exist, Valgo's default English locale will be used. If you wish to change the default locale, you should use a Factory function, which is explained in the Factory section.

  • Changing the locale entries In the example below, we are changing the entry for the "Not Blank" error. Since we are not specifying the localeCode, we are using and replacing the default English locale. However, you can also specify another localeCode if necessary.

    // Creating a new validation session and changing a locale entry
    val := v.New(v.Options{
      Locale: &Locale{
      	  ErrorKeyNotBlank: "{{title}} should not be blank",
        }
    })
    
    // Testing the output
    val := val.Check(v.String(" ", "name").Not().Blank())
    
    out, _ := json.MarshalIndent(val.Error(), "", "  ")
    fmt.Println(string(out))
    

    output:

    {
      "name": [
        "Name should not be blank"
      ]
    }
    
  • Adding a new locale As mentioned previously, Valgo currently only has the English, Spanish and German locales, but we hope to have more soon. However, you can add your own custom locale. Below is an example using the Estonian language:

    // Creating a new validation session and adding a new locale with two entries
    val := v.New(v.Options{
      LocaleCode: "ee",
      Locale: &Locale{
      	  ErrorKeyNotBlank: "{{title}} ei tohi olla tühi",
        ErrorKeyNotFalse: "{{title}} ei tohi olla vale",
        }
    })
    
    // Testing the output
    val := val.
      Is(v.String(" ", "name").Not().Blank()).
      Is(v.Bool(false, "active").Not().False())
    
    out, _ := json.MarshalIndent(val.Error(), "", "  ")
    fmt.Println(string(out))
    

    output:

    {
      "name": [
        "Name ei tohi olla tühi"
      ],
      "active": [
        "Active ei tohi olla vale"
      ]
    }
    

    For entries not specified in the custom locale, the default Valgo locale (English) will be used. If you wish to change the default locale, you can use the Factory function, which is further explained in the Factory section.

We welcome pull requests for adding new locale messages, but please ensure that the translations are of high quality.

Managing common options with Factory

Valgo provides the Factory() function which allows you to create a valgo factory. With a valgo factory, you can create Validation sessions with preset options, avoiding having to pass options each time when a Validation is created. This allows more flexibility and easier management of options when creating Validation sessions.

The Factory function takes a parameter of type FactoryOptions struct, which allows you to modify the default locale code, add new locales, and set a custom JSON marshaler for errors. The ValidationFactory instance created by this function has all the functions to create Validations available in the package level (Is(), In(), Check(), New()) which creates a new Validation session with the preset options in the factory.

In the following example, we create a Factory with the default locale code set to Spanish, a new locale added for Estonian. This factory instance enables us to create validation sessions.

factory := v.Factory(v.FactoryOptions{
  LocaleCodeDefault: "es",
  Locales: map[string]*Locale{
      "ee": {
          v.ErrorKeyNotBlank: "{{title}} ei tohi olla tühi",
          v.ErrorKeyNotFalse: "{{title}} ei tohi olla vale",
      },
  }
})

// Error will contain the spanish error "Nombre no puede estar en blanco"
v1 := factory.Is(String(" ", "nombre").NotBlank())

// Error will contain the spanish error "Nime ei tohi olla tühi"
v2 := factory.New(Options{LocaleCode: "ee"}).Is(String(" ", "nime").Not().Blank())

Custom errors JSON output with Factory

It is possible to use the MarshalJsonFunc parameter of Factory for customizing the JSON output for errors.

customMarshalJson := func(e *Error) ([]byte, error) {

  errors := map[string]interface{}{}

  for k, v := range e.errors {
    errors[k] = v.Messages()
  }

  // Add a root key level called errors, which is not set by default in the Valgo implementation.
  return json.Marshal(map[string]map[string]interface{}{"errors": errors})
}

// Set the custom Marshal JSON function
factory := v.Factory(v.FactoryOptions{
  MarshalJsonFunc: customMarshalJson
})

// Now validate something to check if the output JSON contains the errors root key

val := factory.Is(v.String("", "name").Not().Empty())

out, _ := json.MarshalIndent(val.Error(), "", "  ")
fmt.Println(string(out))

output:

{
  "errors": {
    "name": [
      "Name can't be empty"
    ]
  }
}

Validators

Validators establish the rules for validating a value. The validators are passed to a Validation session.

For each primitive Golang value type, Valgo provides a Validator. A Validator has different functions that set its value's validation rules.

Although Valgo has multiple types of validators, it can be extended with custom validators. Check the section Extending Valgo with Custom Validators for more information.

Validator value's name and title.

Validators only require the value to be validated, so, for example, the following code validates a string value by checking if it is empty.

val := v.New(v.String("").Empty())

val.Error() output:

{
  "value_0": [
	  "Value 0 can't be empty",
  ]
}

In the example above, since we didn't specify a name for the value, Valgo generates a value_0 name and consequently the Value 0 title in the error message.

However, Validators allow you, optionally, to specify the value's name and title, as shown below:

Validator with value's name:

val := v.New(v.String("", "company_name").Not().Empty())

val.Error() output:

{
  "company_name": [
	  "Company name can't be empty",
  ]
}

Validator with value's name and title:

val := v.New(v.String("", "company_name", "Customer").Not().Empty())

val.Error() output:

{
  "company_name": [
	  "Customer can't be empty",
  ]
}

Not() validator function

Valgo validators have a Not() function to invert the boolean value associated with the next validator rule function.

In the following example, the call to Valid() will return false because Not() inverts the boolean value associated with the Zero() function.

valid := Is(v.Number(0).Not().Zero()).Valid()

fmt.Println(valid)

output:

false

String validator

The ValidatorString provides functions for setting validation rules for a string type value, or a custom type based on a string.

Below is a valid example for every String validator rule.

v.Is(v.String("Dennis Ritchie").EqualTo("Dennis Ritchie"))
v.Is(v.String("Steve Jobs").GreaterThan("Bill Gates"))
v.Is(v.String("Steve Jobs").GreaterOrEqualTo("Elon Musk"))
v.Is(v.String("C#").LessThan("Go"))
v.Is(v.String("Go").LessOrEqualTo("Golang"))
v.Is(v.String("Rust").Between("Go", "Typescript")) // Inclusive
v.Is(v.String("").Empty())
v.Is(v.String(" ").Blank())
v.Is(v.String("Dart").Passing(func(val string) bool { return val == "Dart" }))
v.Is(v.String("processing").InSlice([]string{"idle", "processing", "ready"})
v.Is(v.String("123456").MaxLength(6))
v.Is(v.String("123").MinLength(3))
v.Is(v.String("1234").MinLength(4))
v.Is(v.String("12345").LengthBetween(4,6)) // Inclusive
regex, _ := regexp.Compile("pre-.+"); v.Is(String("pre-approved").MatchingTo(regex))

String pointer validator

The ValidatorStringP provides functions for setting validation rules for a string type pointer, or a custom type based on a string pointer.

Below is a valid example for every String pointer validator rule.

x := "Dennis Ritchie"; v.Is(v.StringP(&x).EqualTo("Dennis Ritchie"))
x := "Steve Jobs";     v.Is(v.StringP(&x).GreaterThan("Bill Gates"))
x := "Steve Jobs";     v.Is(v.StringP(&x).GreaterOrEqualTo("Elon Musk"))
x := "C#";             v.Is(v.StringP(&x).LessThan("Go"))
x := "Go";             v.Is(v.StringP(&x).LessOrEqualTo("Golang"))
x := "Rust";           v.Is(v.StringP(&x).Between("Go", "Typescript")) // Inclusive
x := "";               v.Is(v.StringP(&x).Empty())
x := " ";              v.Is(v.StringP(&x).Blank())
x := "Dart";           v.Is(v.StringP(&x).Passing(func(val *string) bool { return *val == "Dart" }))
x := "processing";     v.Is(v.StringP(&x).InSlice([]string{"idle", "processing", "ready"})
x := "123456";         v.Is(v.StringP(&x).MaxLength(6))
x := "123";            v.Is(v.StringP(&x).MinLength(3))
x := "1234";           v.Is(v.StringP(&x).MinLength(4))
x := "12345";          v.Is(v.StringP(&x).LengthBetween(4,6)) // Inclusive
x := "pre-approved"; regex, _ := regexp.Compile("pre-.+"); v.Is(StringP(&x).MatchingTo(regex))
x := "";               v.Is(v.StringP(&x).EmptyOrNil())
x := " ";              v.Is(v.StringP(&x).BlankOrNil())
var x *string;         v.Is(v.StringP(x).Nil())

Number validator

The Number validator provides functions for setting validation rules for a TypeNumber value, or a custom type based on a TypeNumber.

TypeNumber is a generic interface defined by Valgo that generalizes any standard Golang type. Below is Valgo's definition of TypeNumber:

type TypeNumber interface {
  ~int |
  ~int8 |
  ~int16 |
  ~int32 |
  ~int64 |
  ~uint |
  ~uint8 |
  ~uint16 |
  ~uint32 |
  ~uint64 |
  ~float32 |
  ~float64
}

Below is a valid example for every Number validator rule.

v.Is(v.Number(10).EqualTo(10))
v.Is(v.Number(11).GreaterThan(10))
v.Is(v.Number(10).GreaterOrEqualTo(10))
v.Is(v.Number(10).LessThan(11))
v.Is(v.Number(10).LessOrEqualTo(10))
v.Is(v.Number(11).Between(10, 12)) // Inclusive
v.Is(v.Number(0).Zero())
v.Is(v.Number(10).Passing(func(val int) bool { return val == 10 }))
v.Is(v.Number(20).InSlice([]int{10, 20, 30}))

Number pointer validator

The Number pointer validator provides functions for setting validation rules for a TypeNumber pointer, or a custom type based on a TypeNumber pointer.

As it's explained in Number validator, the TypeNumber is a generic interface defined by Valgo that generalizes any standard Golang type.

Below is a valid example for every Number pointer validator rule.

x := 10;    v.Is(v.NumberP(&x).EqualTo(10))
x := 11;    v.Is(v.NumberP(&x).GreaterThan(10))
x := 10;    v.Is(v.NumberP(&x).GreaterOrEqualTo(10))
x := 10;    v.Is(v.NumberP(&x).LessThan(11))
x := 10;    v.Is(v.NumberP(&x).LessOrEqualTo(10))
x := 11;    v.Is(v.NumberP(&x).Between(10, 12)) // Inclusive
x := 0;     v.Is(v.NumberP(&x).Zero())
x := 10;    v.Is(v.NumberP(&x).Passing(func(val *int) bool { return *val == 10 }))
x := 20;    v.Is(v.NumberP(&x).InSlice([]int{10, 20, 30}))
x := 0;     v.Is(v.NumberP(&x).ZeroOrNil())
var x *int; v.Is(v.NumberP(x).Nil())

Number specific type validators

While the validator Number works with all golang number types, Valgo also has a validator for each type. You can use them if you prefer or need a stronger safe type code.

Following is a list of functions for every specific number type validator, along with their equivalent pointer validators.

Int(v int)         IntP(v *int)
Int8(v int8)       Int8P(v *int8)
Int16(v int16)     Int16P(v *int16)
Int32(v int32)     Int32P(v *int32)
Int64(v int64)     Int64P(v *int64)
Uint(v uint)       UintP(v *uint)
Uint8(v uint8)     Uint8P(v *uint8)
Uint16(v uint16)   Uint16P(v *uint16)
Uint32(v uint32)   Uint32P(v *uint32)
Uint64(v uint64)   Uint64P(v *uint64)
Float32(v float32) Float32P(v *float32)
Float64(v float64) Float64P(v *float64)
Byte(v byte)       ByteP(v *byte)
Rune(v byte)       RuneP(v *byte)

These validators have the same rule functions as the Number validator.

Similar to the Number validator, custom types can be passed based on the specific number type.

Bool validator

The Bool validator provides functions for setting validation rules for a bool type value, or a custom type based on a bool.

Below is a valid example for every Bool validator rule.

v.Is(v.Bool(true).EqualTo(true))
v.Is(v.Bool(true).True())
v.Is(v.Bool(false).False())
v.Is(v.Bool(true).Passing(func(val bool) bool { return val == true }))
v.Is(v.Bool(true).InSlice([]string{true, false}))

Boolean pointer validator

The Bool pointer validator provides functions for setting validation rules for a bool pointer, or a custom type based on a bool pointer.

Below is a valid example for every Bool pointer validator rule.

x := true;   v.Is(v.BoolP(&x).EqualTo(true))
x := true;   v.Is(v.BoolP(&x).True())
x := false;  v.Is(v.BoolP(&x).False())
x := true;   v.Is(v.BoolP(&x).Passing(func(val *bool) bool { return val == true }))
x := true;   v.Is(v.BoolP(&x).InSlice([]string{true, false}))
x := false;  v.Is(v.BoolP(&x).FalseOrNil())
var x *bool; v.Is(v.BoolP(x).Nil())

Any validator

With the Any validator, you can set validation rules for any value or pointer.

Below is a valid example of every Any validator rule.

v.Is(v.Any("react").EqualTo("react"))
v.Is(v.Any("svelte").Passing(func(val *bool) bool { return val == "svelte" }))
var x *bool; v.Is(v.Any(x).Nil())

For the EqualTo(v any) rule function, the parameter type must match the type used by the Any() function, otherwise it will be invalid. In the following example, since the value passed to the Any(...) function is int, and EqualTo(...) compares it with int64, the validation is invalid.

valid := v.Is(v.Any(10).EqualTo(int64(10))).Valid()
fmt.Println(valid)

output

false

If a pointer is used, the same pointer must be passed to EqualTo(v any) as it is passed to Any(v any), in order to get a valid validation. The following example illustrates it.

// Valid since the same pointers are compared
numberA := 10
v.Is(v.Any(&numberA).EqualTo(&numberA)).Valid()

// Invalid since different pointers are compared
numberB := 10
v.Is(v.Any(&numberA).EqualTo(&numberB)).Valid()

Custom type validators

All golang validators allow to pass a custom type based on its value type. Bellow some valid examples.

type Status string
var status Status = "up"
val := v.Is(v.String(status).InSlice([]Status{"down", "up", "paused"}))

type Level int
var level Level = 1
val = v.Is(v.Int(level).LessThan(Level(2)))

type Stage int64
var stage Stage = 2
val := v.Is(v.NumberP(&stage).GreaterThan(Stage(1)))

Extending Valgo with custom validators

While all validators in Golang provide a Passing(...) function, which allows you to use a custom validator function, Valgo also allows you to create your own validator.

With this functionality Valgo can be extended with Validator libraries, which we encourage the community to do.

For example, let's say we want to create a validation for the following ID struct, where a user must provide at least one property.

The struct to validate:

// Type to validate
type ID struct {
  Phone string
  Email string
}

the custom validator code:

// The custom validator type
type ValidatorID struct {
	context *valgo.ValidatorContext
}

// The custom validator implementation of `valgo.Validator`
func (validator *ValidatorID) Context() *valgo.ValidatorContext {
	return validator.context
}

// Here is the function that passes the value to the custom validator
func IDValue(value ID, nameAndTitle ...string) *ValidatorID {
	return &ValidatorID{context: valgo.NewContext(value, nameAndTitle...)}
}

// The Empty rule implementation
func (validator *ValidatorID) Empty(template ...string) *ValidatorID {
	validator.context.Add(
		func() bool {
			return len(strings.Trim(validator.context.Value().(ID).Phone, " ")) == 0 &&
				len(strings.Trim(validator.context.Value().(ID).Email, " ")) == 0
		},
		v.ErrorKeyEmpty, template...)

	return validator
}

// It would be possible to create a rule NotEmpty() instead of Empty(), but if you add a Not() function then your validator will be more flexible.

func (validator *ValidatorID) Not() *ValidatorID {
	validator.context.Not()

	return validator
}

using our validator:

val := v.Is(IDValue(ID{}, "id").Not().Empty())

out, _ := json.MarshalIndent(val.Error(), "", "  ")
fmt.Println(string(out))

output:

{
  "identification": [
	  "Id can't be empty"
  ]
}

List of rules by validator type

  • String validator

    • EqualTo
    • GreaterThan
    • GreaterOrEqualTo
    • LessThan
    • LessOrEqualTo
    • Between
    • Empty
    • Blank
    • Passing
    • InSlice
    • MatchingTo
    • MaxLength
    • MinLength
    • Length
    • LengthBetween
  • StringP validator - for string pointer

    • EqualTo
    • GreaterThan
    • GreaterOrEqualTo
    • LessThan
    • LessOrEqualTo
    • Between
    • Empty
    • Blank
    • Passing
    • InSlice
    • MatchingTo
    • MaxLength
    • MinLength
    • Length
    • LengthBetween
    • BlankOrNil
    • EmptyOrNil
    • Nil
  • Bool validator

    • EqualTo
    • Passing
    • True
    • False
    • InSlice
  • BoolP validator - for boolean pointer

    • EqualTo
    • Passing
    • True
    • False
    • InSlice
    • FalseOrNil
    • Nil
  • Number and Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Float32, Float64, Byte, Rune - for number pointer

    • EqualTo
    • GreaterThan
    • GreaterOrEqualTo
    • LessThan
    • LessOrEqualTo
    • Between
    • Zero
    • InSlice
    • Passing
  • NumberP and IntP, Int8P, Int16P, Int32P, Int64P, UintP, Uint8P, Uint16P, Uint32P, Uint64P, Float32P, Float64P, ByteP, RuneP - for number pointer

    • EqualTo
    • GreaterThan
    • GreaterOrEqualTo
    • LessThan
    • LessOrEqualTo
    • Between
    • Zero
    • InSlice
    • Passing
    • ZeroOrNil
    • Nil
  • Any validator

    • EqualTo
    • Passing
    • Nil

Github Code Contribution Guide

We welcome contributions to our project! To make the process smooth and efficient, please follow these guidelines when submitting code:

  • Discuss changes with the community: We encourage contributors to discuss their proposed changes or improvements with the community before starting to code. This ensures that the changes align with the focus and purpose of the project, and that other contributors are aware of the work being done.

  • Make commits small and cohesive: It is important to keep your commits focused on a single task or change. This makes it easier to review and understand your changes.

  • Check code formatting with go fmt: Before submitting your code, please ensure that it is properly formatted using the go fmt command.

  • Make tests to cover your changes: Please include tests that cover the changes you have made. This ensures that your code is functional and reduces the likelihood of bugs.

  • Update golang docs and README to cover your changes: If you have made changes that affect documentation or the README file, please update them accordingly.

  • Keep a respectful language with a collaborative tune: We value a positive and collaborative community. Please use respectful language when communicating with other contributors or maintainers.

License

Copyright © 2023 Carlos Forero

Valgo is released under the MIT License

Documentation

Overview

Valgo is a type-safe, expressive, and extensible validator library for Golang. Valgo is built with generics, so Go 1.18 or higher is required.

Valgo differs from other Golang validation libraries in that the rules are written in functions and not in struct tags. This allows greater flexibility and freedom when it comes to where and how data is validated.

Additionally, Valgo supports customizing and localizing validation messages.

Code generated by Valgo; DO NOT EDIT.

Code generated by Valgo; DO NOT EDIT.

Code generated by Valgo; DO NOT EDIT.

Code generated by Valgo; DO NOT EDIT.

Example
val := Is(String("Bob", "full_name").Not().Blank().OfLengthBetween(4, 20)).
	Is(Number(17, "age").GreaterThan(18))

if !val.Valid() {
	out, _ := json.MarshalIndent(val.Error(), "", "  ")
	fmt.Println(string(out))
}
Output:

{
  "age": [
    "Age must be greater than \"18\""
  ],
  "full_name": [
    "Full name must have a length between \"4\" and \"20\""
  ]
}

Index

Examples

Constants

View Source
const (
	ErrorKeyBetween    = "between"
	ErrorKeyNotBetween = "not_between"

	ErrorKeyBlank    = "blank"
	ErrorKeyNotBlank = "not_blank"

	ErrorKeyEmpty    = "empty"
	ErrorKeyNotEmpty = "not_empty"

	ErrorKeyEqualTo    = "equal_to"
	ErrorKeyNotEqualTo = "not_equal_to"

	ErrorKeyFalse    = "false"
	ErrorKeyNotFalse = "not_false"

	ErrorKeyGreaterOrEqualTo    = "greater_equal_to"
	ErrorKeyNotGreaterOrEqualTo = "not_greater_equal_to"

	ErrorKeyGreaterThan    = "greater_than"
	ErrorKeyNotGreaterThan = "not_greater_than"

	ErrorKeyInSlice    = "in_slice"
	ErrorKeyNotInSlice = "not_in_slice"

	ErrorKeyLength    = "length"
	ErrorKeyNotLength = "not_length"

	ErrorKeyLengthBetween    = "length_between"
	ErrorKeyNotLengthBetween = "not_length_between"

	ErrorKeyLessOrEqualTo    = "less_or_equal_to"
	ErrorKeyNotLessOrEqualTo = "not_less_or_equal_to"

	ErrorKeyLessThan    = "less_than"
	ErrorKeyNotLessThan = "not_less_than"

	ErrorKeyMatchingTo    = "matching_to"
	ErrorKeyNotMatchingTo = "not_matching_to"

	ErrorKeyMaxLength    = "max_length"
	ErrorKeyNotMaxLength = "not_max_length"

	ErrorKeyMinLength    = "min_length"
	ErrorKeyNotMinLength = "not_min_length"

	ErrorKeyNil    = "nil"
	ErrorKeyNotNil = "not_nil"

	ErrorKeyPassing    = "passing"
	ErrorKeyNotPassing = "not_passing"

	ErrorKeyTrue    = "true"
	ErrorKeyNotTrue = "not_true"

	ErrorKeyZero    = "zero"
	ErrorKeyNotZero = "not_zero"
)
View Source
const (
	LocaleCodeEn = "en"
	LocaleCodeEs = "es"
	LocaleCodeDe = "de"
)

Variables

This section is empty.

Functions

func TestValidatorByteBetweenInvalid

func TestValidatorByteBetweenInvalid(t *testing.T)

func TestValidatorByteBetweenValid

func TestValidatorByteBetweenValid(t *testing.T)

func TestValidatorByteEqualToInvalid

func TestValidatorByteEqualToInvalid(t *testing.T)

func TestValidatorByteEqualToValid

func TestValidatorByteEqualToValid(t *testing.T)

func TestValidatorByteGreaterOrEqualToInvalid

func TestValidatorByteGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorByteGreaterOrEqualToValid

func TestValidatorByteGreaterOrEqualToValid(t *testing.T)

func TestValidatorByteGreaterThanInvalid

func TestValidatorByteGreaterThanInvalid(t *testing.T)

func TestValidatorByteGreaterThanValid

func TestValidatorByteGreaterThanValid(t *testing.T)

func TestValidatorByteInSliceInvalid

func TestValidatorByteInSliceInvalid(t *testing.T)

func TestValidatorByteInSliceValid

func TestValidatorByteInSliceValid(t *testing.T)

func TestValidatorByteLessOrEqualToInvalid

func TestValidatorByteLessOrEqualToInvalid(t *testing.T)

func TestValidatorByteLessOrEqualToValid

func TestValidatorByteLessOrEqualToValid(t *testing.T)

func TestValidatorByteLessThanInvalid

func TestValidatorByteLessThanInvalid(t *testing.T)

func TestValidatorByteLessThanValid

func TestValidatorByteLessThanValid(t *testing.T)

func TestValidatorByteNot

func TestValidatorByteNot(t *testing.T)

func TestValidatorBytePBetweenInvalid

func TestValidatorBytePBetweenInvalid(t *testing.T)

func TestValidatorBytePBetweenValid

func TestValidatorBytePBetweenValid(t *testing.T)

func TestValidatorBytePEqualToInvalid

func TestValidatorBytePEqualToInvalid(t *testing.T)

func TestValidatorBytePEqualToValid

func TestValidatorBytePEqualToValid(t *testing.T)

func TestValidatorBytePGreaterOrEqualToInvalid

func TestValidatorBytePGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorBytePGreaterOrEqualToValid

func TestValidatorBytePGreaterOrEqualToValid(t *testing.T)

func TestValidatorBytePGreaterThanInvalid

func TestValidatorBytePGreaterThanInvalid(t *testing.T)

func TestValidatorBytePGreaterThanValid

func TestValidatorBytePGreaterThanValid(t *testing.T)

func TestValidatorBytePInSliceInvalid

func TestValidatorBytePInSliceInvalid(t *testing.T)

func TestValidatorBytePInSliceValid

func TestValidatorBytePInSliceValid(t *testing.T)

func TestValidatorBytePLessOrEqualToInvalid

func TestValidatorBytePLessOrEqualToInvalid(t *testing.T)

func TestValidatorBytePLessOrEqualToValid

func TestValidatorBytePLessOrEqualToValid(t *testing.T)

func TestValidatorBytePLessThanInvalid

func TestValidatorBytePLessThanInvalid(t *testing.T)

func TestValidatorBytePLessThanValid

func TestValidatorBytePLessThanValid(t *testing.T)

func TestValidatorBytePNilIsInvalid

func TestValidatorBytePNilIsInvalid(t *testing.T)

func TestValidatorBytePNilIsValid

func TestValidatorBytePNilIsValid(t *testing.T)

func TestValidatorBytePNot

func TestValidatorBytePNot(t *testing.T)

func TestValidatorBytePPassingInvalid

func TestValidatorBytePPassingInvalid(t *testing.T)

func TestValidatorBytePPassingValid

func TestValidatorBytePPassingValid(t *testing.T)

func TestValidatorBytePZeroInvalid

func TestValidatorBytePZeroInvalid(t *testing.T)

func TestValidatorBytePZeroOrNilInvalid

func TestValidatorBytePZeroOrNilInvalid(t *testing.T)

func TestValidatorBytePZeroOrNilValid

func TestValidatorBytePZeroOrNilValid(t *testing.T)

func TestValidatorBytePZeroValid

func TestValidatorBytePZeroValid(t *testing.T)

func TestValidatorBytePassingInvalid

func TestValidatorBytePassingInvalid(t *testing.T)

func TestValidatorBytePassingValid

func TestValidatorBytePassingValid(t *testing.T)

func TestValidatorByteZeroInvalid

func TestValidatorByteZeroInvalid(t *testing.T)

func TestValidatorByteZeroValid

func TestValidatorByteZeroValid(t *testing.T)

func TestValidatorFloat32BetweenInvalid

func TestValidatorFloat32BetweenInvalid(t *testing.T)

func TestValidatorFloat32BetweenValid

func TestValidatorFloat32BetweenValid(t *testing.T)

func TestValidatorFloat32EqualToInvalid

func TestValidatorFloat32EqualToInvalid(t *testing.T)

func TestValidatorFloat32EqualToValid

func TestValidatorFloat32EqualToValid(t *testing.T)

func TestValidatorFloat32GreaterOrEqualToInvalid

func TestValidatorFloat32GreaterOrEqualToInvalid(t *testing.T)

func TestValidatorFloat32GreaterOrEqualToValid

func TestValidatorFloat32GreaterOrEqualToValid(t *testing.T)

func TestValidatorFloat32GreaterThanInvalid

func TestValidatorFloat32GreaterThanInvalid(t *testing.T)

func TestValidatorFloat32GreaterThanValid

func TestValidatorFloat32GreaterThanValid(t *testing.T)

func TestValidatorFloat32InSliceInvalid

func TestValidatorFloat32InSliceInvalid(t *testing.T)

func TestValidatorFloat32InSliceValid

func TestValidatorFloat32InSliceValid(t *testing.T)

func TestValidatorFloat32LessOrEqualToInvalid

func TestValidatorFloat32LessOrEqualToInvalid(t *testing.T)

func TestValidatorFloat32LessOrEqualToValid

func TestValidatorFloat32LessOrEqualToValid(t *testing.T)

func TestValidatorFloat32LessThanInvalid

func TestValidatorFloat32LessThanInvalid(t *testing.T)

func TestValidatorFloat32LessThanValid

func TestValidatorFloat32LessThanValid(t *testing.T)

func TestValidatorFloat32Not

func TestValidatorFloat32Not(t *testing.T)

func TestValidatorFloat32PBetweenInvalid

func TestValidatorFloat32PBetweenInvalid(t *testing.T)

func TestValidatorFloat32PBetweenValid

func TestValidatorFloat32PBetweenValid(t *testing.T)

func TestValidatorFloat32PEqualToInvalid

func TestValidatorFloat32PEqualToInvalid(t *testing.T)

func TestValidatorFloat32PEqualToValid

func TestValidatorFloat32PEqualToValid(t *testing.T)

func TestValidatorFloat32PGreaterOrEqualToInvalid

func TestValidatorFloat32PGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorFloat32PGreaterOrEqualToValid

func TestValidatorFloat32PGreaterOrEqualToValid(t *testing.T)

func TestValidatorFloat32PGreaterThanInvalid

func TestValidatorFloat32PGreaterThanInvalid(t *testing.T)

func TestValidatorFloat32PGreaterThanValid

func TestValidatorFloat32PGreaterThanValid(t *testing.T)

func TestValidatorFloat32PInSliceInvalid

func TestValidatorFloat32PInSliceInvalid(t *testing.T)

func TestValidatorFloat32PInSliceValid

func TestValidatorFloat32PInSliceValid(t *testing.T)

func TestValidatorFloat32PLessOrEqualToInvalid

func TestValidatorFloat32PLessOrEqualToInvalid(t *testing.T)

func TestValidatorFloat32PLessOrEqualToValid

func TestValidatorFloat32PLessOrEqualToValid(t *testing.T)

func TestValidatorFloat32PLessThanInvalid

func TestValidatorFloat32PLessThanInvalid(t *testing.T)

func TestValidatorFloat32PLessThanValid

func TestValidatorFloat32PLessThanValid(t *testing.T)

func TestValidatorFloat32PNilIsInvalid

func TestValidatorFloat32PNilIsInvalid(t *testing.T)

func TestValidatorFloat32PNilIsValid

func TestValidatorFloat32PNilIsValid(t *testing.T)

func TestValidatorFloat32PNot

func TestValidatorFloat32PNot(t *testing.T)

func TestValidatorFloat32PPassingInvalid

func TestValidatorFloat32PPassingInvalid(t *testing.T)

func TestValidatorFloat32PPassingValid

func TestValidatorFloat32PPassingValid(t *testing.T)

func TestValidatorFloat32PZeroInvalid

func TestValidatorFloat32PZeroInvalid(t *testing.T)

func TestValidatorFloat32PZeroOrNilInvalid

func TestValidatorFloat32PZeroOrNilInvalid(t *testing.T)

func TestValidatorFloat32PZeroOrNilValid

func TestValidatorFloat32PZeroOrNilValid(t *testing.T)

func TestValidatorFloat32PZeroValid

func TestValidatorFloat32PZeroValid(t *testing.T)

func TestValidatorFloat32PassingInvalid

func TestValidatorFloat32PassingInvalid(t *testing.T)

func TestValidatorFloat32PassingValid

func TestValidatorFloat32PassingValid(t *testing.T)

func TestValidatorFloat32ZeroInvalid

func TestValidatorFloat32ZeroInvalid(t *testing.T)

func TestValidatorFloat32ZeroValid

func TestValidatorFloat32ZeroValid(t *testing.T)

func TestValidatorFloat64BetweenInvalid

func TestValidatorFloat64BetweenInvalid(t *testing.T)

func TestValidatorFloat64BetweenValid

func TestValidatorFloat64BetweenValid(t *testing.T)

func TestValidatorFloat64EqualToInvalid

func TestValidatorFloat64EqualToInvalid(t *testing.T)

func TestValidatorFloat64EqualToValid

func TestValidatorFloat64EqualToValid(t *testing.T)

func TestValidatorFloat64GreaterOrEqualToInvalid

func TestValidatorFloat64GreaterOrEqualToInvalid(t *testing.T)

func TestValidatorFloat64GreaterOrEqualToValid

func TestValidatorFloat64GreaterOrEqualToValid(t *testing.T)

func TestValidatorFloat64GreaterThanInvalid

func TestValidatorFloat64GreaterThanInvalid(t *testing.T)

func TestValidatorFloat64GreaterThanValid

func TestValidatorFloat64GreaterThanValid(t *testing.T)

func TestValidatorFloat64InSliceInvalid

func TestValidatorFloat64InSliceInvalid(t *testing.T)

func TestValidatorFloat64InSliceValid

func TestValidatorFloat64InSliceValid(t *testing.T)

func TestValidatorFloat64LessOrEqualToInvalid

func TestValidatorFloat64LessOrEqualToInvalid(t *testing.T)

func TestValidatorFloat64LessOrEqualToValid

func TestValidatorFloat64LessOrEqualToValid(t *testing.T)

func TestValidatorFloat64LessThanInvalid

func TestValidatorFloat64LessThanInvalid(t *testing.T)

func TestValidatorFloat64LessThanValid

func TestValidatorFloat64LessThanValid(t *testing.T)

func TestValidatorFloat64Not

func TestValidatorFloat64Not(t *testing.T)

func TestValidatorFloat64PBetweenInvalid

func TestValidatorFloat64PBetweenInvalid(t *testing.T)

func TestValidatorFloat64PBetweenValid

func TestValidatorFloat64PBetweenValid(t *testing.T)

func TestValidatorFloat64PEqualToInvalid

func TestValidatorFloat64PEqualToInvalid(t *testing.T)

func TestValidatorFloat64PEqualToValid

func TestValidatorFloat64PEqualToValid(t *testing.T)

func TestValidatorFloat64PGreaterOrEqualToInvalid

func TestValidatorFloat64PGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorFloat64PGreaterOrEqualToValid

func TestValidatorFloat64PGreaterOrEqualToValid(t *testing.T)

func TestValidatorFloat64PGreaterThanInvalid

func TestValidatorFloat64PGreaterThanInvalid(t *testing.T)

func TestValidatorFloat64PGreaterThanValid

func TestValidatorFloat64PGreaterThanValid(t *testing.T)

func TestValidatorFloat64PInSliceInvalid

func TestValidatorFloat64PInSliceInvalid(t *testing.T)

func TestValidatorFloat64PInSliceValid

func TestValidatorFloat64PInSliceValid(t *testing.T)

func TestValidatorFloat64PLessOrEqualToInvalid

func TestValidatorFloat64PLessOrEqualToInvalid(t *testing.T)

func TestValidatorFloat64PLessOrEqualToValid

func TestValidatorFloat64PLessOrEqualToValid(t *testing.T)

func TestValidatorFloat64PLessThanInvalid

func TestValidatorFloat64PLessThanInvalid(t *testing.T)

func TestValidatorFloat64PLessThanValid

func TestValidatorFloat64PLessThanValid(t *testing.T)

func TestValidatorFloat64PNilIsInvalid

func TestValidatorFloat64PNilIsInvalid(t *testing.T)

func TestValidatorFloat64PNilIsValid

func TestValidatorFloat64PNilIsValid(t *testing.T)

func TestValidatorFloat64PNot

func TestValidatorFloat64PNot(t *testing.T)

func TestValidatorFloat64PPassingInvalid

func TestValidatorFloat64PPassingInvalid(t *testing.T)

func TestValidatorFloat64PPassingValid

func TestValidatorFloat64PPassingValid(t *testing.T)

func TestValidatorFloat64PZeroInvalid

func TestValidatorFloat64PZeroInvalid(t *testing.T)

func TestValidatorFloat64PZeroOrNilInvalid

func TestValidatorFloat64PZeroOrNilInvalid(t *testing.T)

func TestValidatorFloat64PZeroOrNilValid

func TestValidatorFloat64PZeroOrNilValid(t *testing.T)

func TestValidatorFloat64PZeroValid

func TestValidatorFloat64PZeroValid(t *testing.T)

func TestValidatorFloat64PassingInvalid

func TestValidatorFloat64PassingInvalid(t *testing.T)

func TestValidatorFloat64PassingValid

func TestValidatorFloat64PassingValid(t *testing.T)

func TestValidatorFloat64ZeroInvalid

func TestValidatorFloat64ZeroInvalid(t *testing.T)

func TestValidatorFloat64ZeroValid

func TestValidatorFloat64ZeroValid(t *testing.T)

func TestValidatorInt16BetweenInvalid

func TestValidatorInt16BetweenInvalid(t *testing.T)

func TestValidatorInt16BetweenValid

func TestValidatorInt16BetweenValid(t *testing.T)

func TestValidatorInt16EqualToInvalid

func TestValidatorInt16EqualToInvalid(t *testing.T)

func TestValidatorInt16EqualToValid

func TestValidatorInt16EqualToValid(t *testing.T)

func TestValidatorInt16GreaterOrEqualToInvalid

func TestValidatorInt16GreaterOrEqualToInvalid(t *testing.T)

func TestValidatorInt16GreaterOrEqualToValid

func TestValidatorInt16GreaterOrEqualToValid(t *testing.T)

func TestValidatorInt16GreaterThanInvalid

func TestValidatorInt16GreaterThanInvalid(t *testing.T)

func TestValidatorInt16GreaterThanValid

func TestValidatorInt16GreaterThanValid(t *testing.T)

func TestValidatorInt16InSliceInvalid

func TestValidatorInt16InSliceInvalid(t *testing.T)

func TestValidatorInt16InSliceValid

func TestValidatorInt16InSliceValid(t *testing.T)

func TestValidatorInt16LessOrEqualToInvalid

func TestValidatorInt16LessOrEqualToInvalid(t *testing.T)

func TestValidatorInt16LessOrEqualToValid

func TestValidatorInt16LessOrEqualToValid(t *testing.T)

func TestValidatorInt16LessThanInvalid

func TestValidatorInt16LessThanInvalid(t *testing.T)

func TestValidatorInt16LessThanValid

func TestValidatorInt16LessThanValid(t *testing.T)

func TestValidatorInt16Not

func TestValidatorInt16Not(t *testing.T)

func TestValidatorInt16PBetweenInvalid

func TestValidatorInt16PBetweenInvalid(t *testing.T)

func TestValidatorInt16PBetweenValid

func TestValidatorInt16PBetweenValid(t *testing.T)

func TestValidatorInt16PEqualToInvalid

func TestValidatorInt16PEqualToInvalid(t *testing.T)

func TestValidatorInt16PEqualToValid

func TestValidatorInt16PEqualToValid(t *testing.T)

func TestValidatorInt16PGreaterOrEqualToInvalid

func TestValidatorInt16PGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorInt16PGreaterOrEqualToValid

func TestValidatorInt16PGreaterOrEqualToValid(t *testing.T)

func TestValidatorInt16PGreaterThanInvalid

func TestValidatorInt16PGreaterThanInvalid(t *testing.T)

func TestValidatorInt16PGreaterThanValid

func TestValidatorInt16PGreaterThanValid(t *testing.T)

func TestValidatorInt16PInSliceInvalid

func TestValidatorInt16PInSliceInvalid(t *testing.T)

func TestValidatorInt16PInSliceValid

func TestValidatorInt16PInSliceValid(t *testing.T)

func TestValidatorInt16PLessOrEqualToInvalid

func TestValidatorInt16PLessOrEqualToInvalid(t *testing.T)

func TestValidatorInt16PLessOrEqualToValid

func TestValidatorInt16PLessOrEqualToValid(t *testing.T)

func TestValidatorInt16PLessThanInvalid

func TestValidatorInt16PLessThanInvalid(t *testing.T)

func TestValidatorInt16PLessThanValid

func TestValidatorInt16PLessThanValid(t *testing.T)

func TestValidatorInt16PNilIsInvalid

func TestValidatorInt16PNilIsInvalid(t *testing.T)

func TestValidatorInt16PNilIsValid

func TestValidatorInt16PNilIsValid(t *testing.T)

func TestValidatorInt16PNot

func TestValidatorInt16PNot(t *testing.T)

func TestValidatorInt16PPassingInvalid

func TestValidatorInt16PPassingInvalid(t *testing.T)

func TestValidatorInt16PPassingValid

func TestValidatorInt16PPassingValid(t *testing.T)

func TestValidatorInt16PZeroInvalid

func TestValidatorInt16PZeroInvalid(t *testing.T)

func TestValidatorInt16PZeroOrNilInvalid

func TestValidatorInt16PZeroOrNilInvalid(t *testing.T)

func TestValidatorInt16PZeroOrNilValid

func TestValidatorInt16PZeroOrNilValid(t *testing.T)

func TestValidatorInt16PZeroValid

func TestValidatorInt16PZeroValid(t *testing.T)

func TestValidatorInt16PassingInvalid

func TestValidatorInt16PassingInvalid(t *testing.T)

func TestValidatorInt16PassingValid

func TestValidatorInt16PassingValid(t *testing.T)

func TestValidatorInt16ZeroInvalid

func TestValidatorInt16ZeroInvalid(t *testing.T)

func TestValidatorInt16ZeroValid

func TestValidatorInt16ZeroValid(t *testing.T)

func TestValidatorInt32BetweenInvalid

func TestValidatorInt32BetweenInvalid(t *testing.T)

func TestValidatorInt32BetweenValid

func TestValidatorInt32BetweenValid(t *testing.T)

func TestValidatorInt32EqualToInvalid

func TestValidatorInt32EqualToInvalid(t *testing.T)

func TestValidatorInt32EqualToValid

func TestValidatorInt32EqualToValid(t *testing.T)

func TestValidatorInt32GreaterOrEqualToInvalid

func TestValidatorInt32GreaterOrEqualToInvalid(t *testing.T)

func TestValidatorInt32GreaterOrEqualToValid

func TestValidatorInt32GreaterOrEqualToValid(t *testing.T)

func TestValidatorInt32GreaterThanInvalid

func TestValidatorInt32GreaterThanInvalid(t *testing.T)

func TestValidatorInt32GreaterThanValid

func TestValidatorInt32GreaterThanValid(t *testing.T)

func TestValidatorInt32InSliceInvalid

func TestValidatorInt32InSliceInvalid(t *testing.T)

func TestValidatorInt32InSliceValid

func TestValidatorInt32InSliceValid(t *testing.T)

func TestValidatorInt32LessOrEqualToInvalid

func TestValidatorInt32LessOrEqualToInvalid(t *testing.T)

func TestValidatorInt32LessOrEqualToValid

func TestValidatorInt32LessOrEqualToValid(t *testing.T)

func TestValidatorInt32LessThanInvalid

func TestValidatorInt32LessThanInvalid(t *testing.T)

func TestValidatorInt32LessThanValid

func TestValidatorInt32LessThanValid(t *testing.T)

func TestValidatorInt32Not

func TestValidatorInt32Not(t *testing.T)

func TestValidatorInt32PBetweenInvalid

func TestValidatorInt32PBetweenInvalid(t *testing.T)

func TestValidatorInt32PBetweenValid

func TestValidatorInt32PBetweenValid(t *testing.T)

func TestValidatorInt32PEqualToInvalid

func TestValidatorInt32PEqualToInvalid(t *testing.T)

func TestValidatorInt32PEqualToValid

func TestValidatorInt32PEqualToValid(t *testing.T)

func TestValidatorInt32PGreaterOrEqualToInvalid

func TestValidatorInt32PGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorInt32PGreaterOrEqualToValid

func TestValidatorInt32PGreaterOrEqualToValid(t *testing.T)

func TestValidatorInt32PGreaterThanInvalid

func TestValidatorInt32PGreaterThanInvalid(t *testing.T)

func TestValidatorInt32PGreaterThanValid

func TestValidatorInt32PGreaterThanValid(t *testing.T)

func TestValidatorInt32PInSliceInvalid

func TestValidatorInt32PInSliceInvalid(t *testing.T)

func TestValidatorInt32PInSliceValid

func TestValidatorInt32PInSliceValid(t *testing.T)

func TestValidatorInt32PLessOrEqualToInvalid

func TestValidatorInt32PLessOrEqualToInvalid(t *testing.T)

func TestValidatorInt32PLessOrEqualToValid

func TestValidatorInt32PLessOrEqualToValid(t *testing.T)

func TestValidatorInt32PLessThanInvalid

func TestValidatorInt32PLessThanInvalid(t *testing.T)

func TestValidatorInt32PLessThanValid

func TestValidatorInt32PLessThanValid(t *testing.T)

func TestValidatorInt32PNilIsInvalid

func TestValidatorInt32PNilIsInvalid(t *testing.T)

func TestValidatorInt32PNilIsValid

func TestValidatorInt32PNilIsValid(t *testing.T)

func TestValidatorInt32PNot

func TestValidatorInt32PNot(t *testing.T)

func TestValidatorInt32PPassingInvalid

func TestValidatorInt32PPassingInvalid(t *testing.T)

func TestValidatorInt32PPassingValid

func TestValidatorInt32PPassingValid(t *testing.T)

func TestValidatorInt32PZeroInvalid

func TestValidatorInt32PZeroInvalid(t *testing.T)

func TestValidatorInt32PZeroOrNilInvalid

func TestValidatorInt32PZeroOrNilInvalid(t *testing.T)

func TestValidatorInt32PZeroOrNilValid

func TestValidatorInt32PZeroOrNilValid(t *testing.T)

func TestValidatorInt32PZeroValid

func TestValidatorInt32PZeroValid(t *testing.T)

func TestValidatorInt32PassingInvalid

func TestValidatorInt32PassingInvalid(t *testing.T)

func TestValidatorInt32PassingValid

func TestValidatorInt32PassingValid(t *testing.T)

func TestValidatorInt32ZeroInvalid

func TestValidatorInt32ZeroInvalid(t *testing.T)

func TestValidatorInt32ZeroValid

func TestValidatorInt32ZeroValid(t *testing.T)

func TestValidatorInt64BetweenInvalid

func TestValidatorInt64BetweenInvalid(t *testing.T)

func TestValidatorInt64BetweenValid

func TestValidatorInt64BetweenValid(t *testing.T)

func TestValidatorInt64EqualToInvalid

func TestValidatorInt64EqualToInvalid(t *testing.T)

func TestValidatorInt64EqualToValid

func TestValidatorInt64EqualToValid(t *testing.T)

func TestValidatorInt64GreaterOrEqualToInvalid

func TestValidatorInt64GreaterOrEqualToInvalid(t *testing.T)

func TestValidatorInt64GreaterOrEqualToValid

func TestValidatorInt64GreaterOrEqualToValid(t *testing.T)

func TestValidatorInt64GreaterThanInvalid

func TestValidatorInt64GreaterThanInvalid(t *testing.T)

func TestValidatorInt64GreaterThanValid

func TestValidatorInt64GreaterThanValid(t *testing.T)

func TestValidatorInt64InSliceInvalid

func TestValidatorInt64InSliceInvalid(t *testing.T)

func TestValidatorInt64InSliceValid

func TestValidatorInt64InSliceValid(t *testing.T)

func TestValidatorInt64LessOrEqualToInvalid

func TestValidatorInt64LessOrEqualToInvalid(t *testing.T)

func TestValidatorInt64LessOrEqualToValid

func TestValidatorInt64LessOrEqualToValid(t *testing.T)

func TestValidatorInt64LessThanInvalid

func TestValidatorInt64LessThanInvalid(t *testing.T)

func TestValidatorInt64LessThanValid

func TestValidatorInt64LessThanValid(t *testing.T)

func TestValidatorInt64Not

func TestValidatorInt64Not(t *testing.T)

func TestValidatorInt64PBetweenInvalid

func TestValidatorInt64PBetweenInvalid(t *testing.T)

func TestValidatorInt64PBetweenValid

func TestValidatorInt64PBetweenValid(t *testing.T)

func TestValidatorInt64PEqualToInvalid

func TestValidatorInt64PEqualToInvalid(t *testing.T)

func TestValidatorInt64PEqualToValid

func TestValidatorInt64PEqualToValid(t *testing.T)

func TestValidatorInt64PGreaterOrEqualToInvalid

func TestValidatorInt64PGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorInt64PGreaterOrEqualToValid

func TestValidatorInt64PGreaterOrEqualToValid(t *testing.T)

func TestValidatorInt64PGreaterThanInvalid

func TestValidatorInt64PGreaterThanInvalid(t *testing.T)

func TestValidatorInt64PGreaterThanValid

func TestValidatorInt64PGreaterThanValid(t *testing.T)

func TestValidatorInt64PInSliceInvalid

func TestValidatorInt64PInSliceInvalid(t *testing.T)

func TestValidatorInt64PInSliceValid

func TestValidatorInt64PInSliceValid(t *testing.T)

func TestValidatorInt64PLessOrEqualToInvalid

func TestValidatorInt64PLessOrEqualToInvalid(t *testing.T)

func TestValidatorInt64PLessOrEqualToValid

func TestValidatorInt64PLessOrEqualToValid(t *testing.T)

func TestValidatorInt64PLessThanInvalid

func TestValidatorInt64PLessThanInvalid(t *testing.T)

func TestValidatorInt64PLessThanValid

func TestValidatorInt64PLessThanValid(t *testing.T)

func TestValidatorInt64PNilIsInvalid

func TestValidatorInt64PNilIsInvalid(t *testing.T)

func TestValidatorInt64PNilIsValid

func TestValidatorInt64PNilIsValid(t *testing.T)

func TestValidatorInt64PNot

func TestValidatorInt64PNot(t *testing.T)

func TestValidatorInt64PPassingInvalid

func TestValidatorInt64PPassingInvalid(t *testing.T)

func TestValidatorInt64PPassingValid

func TestValidatorInt64PPassingValid(t *testing.T)

func TestValidatorInt64PZeroInvalid

func TestValidatorInt64PZeroInvalid(t *testing.T)

func TestValidatorInt64PZeroOrNilInvalid

func TestValidatorInt64PZeroOrNilInvalid(t *testing.T)

func TestValidatorInt64PZeroOrNilValid

func TestValidatorInt64PZeroOrNilValid(t *testing.T)

func TestValidatorInt64PZeroValid

func TestValidatorInt64PZeroValid(t *testing.T)

func TestValidatorInt64PassingInvalid

func TestValidatorInt64PassingInvalid(t *testing.T)

func TestValidatorInt64PassingValid

func TestValidatorInt64PassingValid(t *testing.T)

func TestValidatorInt64ZeroInvalid

func TestValidatorInt64ZeroInvalid(t *testing.T)

func TestValidatorInt64ZeroValid

func TestValidatorInt64ZeroValid(t *testing.T)

func TestValidatorInt8BetweenInvalid

func TestValidatorInt8BetweenInvalid(t *testing.T)

func TestValidatorInt8BetweenValid

func TestValidatorInt8BetweenValid(t *testing.T)

func TestValidatorInt8EqualToInvalid

func TestValidatorInt8EqualToInvalid(t *testing.T)

func TestValidatorInt8EqualToValid

func TestValidatorInt8EqualToValid(t *testing.T)

func TestValidatorInt8GreaterOrEqualToInvalid

func TestValidatorInt8GreaterOrEqualToInvalid(t *testing.T)

func TestValidatorInt8GreaterOrEqualToValid

func TestValidatorInt8GreaterOrEqualToValid(t *testing.T)

func TestValidatorInt8GreaterThanInvalid

func TestValidatorInt8GreaterThanInvalid(t *testing.T)

func TestValidatorInt8GreaterThanValid

func TestValidatorInt8GreaterThanValid(t *testing.T)

func TestValidatorInt8InSliceInvalid

func TestValidatorInt8InSliceInvalid(t *testing.T)

func TestValidatorInt8InSliceValid

func TestValidatorInt8InSliceValid(t *testing.T)

func TestValidatorInt8LessOrEqualToInvalid

func TestValidatorInt8LessOrEqualToInvalid(t *testing.T)

func TestValidatorInt8LessOrEqualToValid

func TestValidatorInt8LessOrEqualToValid(t *testing.T)

func TestValidatorInt8LessThanInvalid

func TestValidatorInt8LessThanInvalid(t *testing.T)

func TestValidatorInt8LessThanValid

func TestValidatorInt8LessThanValid(t *testing.T)

func TestValidatorInt8Not

func TestValidatorInt8Not(t *testing.T)

func TestValidatorInt8PBetweenInvalid

func TestValidatorInt8PBetweenInvalid(t *testing.T)

func TestValidatorInt8PBetweenValid

func TestValidatorInt8PBetweenValid(t *testing.T)

func TestValidatorInt8PEqualToInvalid

func TestValidatorInt8PEqualToInvalid(t *testing.T)

func TestValidatorInt8PEqualToValid

func TestValidatorInt8PEqualToValid(t *testing.T)

func TestValidatorInt8PGreaterOrEqualToInvalid

func TestValidatorInt8PGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorInt8PGreaterOrEqualToValid

func TestValidatorInt8PGreaterOrEqualToValid(t *testing.T)

func TestValidatorInt8PGreaterThanInvalid

func TestValidatorInt8PGreaterThanInvalid(t *testing.T)

func TestValidatorInt8PGreaterThanValid

func TestValidatorInt8PGreaterThanValid(t *testing.T)

func TestValidatorInt8PInSliceInvalid

func TestValidatorInt8PInSliceInvalid(t *testing.T)

func TestValidatorInt8PInSliceValid

func TestValidatorInt8PInSliceValid(t *testing.T)

func TestValidatorInt8PLessOrEqualToInvalid

func TestValidatorInt8PLessOrEqualToInvalid(t *testing.T)

func TestValidatorInt8PLessOrEqualToValid

func TestValidatorInt8PLessOrEqualToValid(t *testing.T)

func TestValidatorInt8PLessThanInvalid

func TestValidatorInt8PLessThanInvalid(t *testing.T)

func TestValidatorInt8PLessThanValid

func TestValidatorInt8PLessThanValid(t *testing.T)

func TestValidatorInt8PNilIsInvalid

func TestValidatorInt8PNilIsInvalid(t *testing.T)

func TestValidatorInt8PNilIsValid

func TestValidatorInt8PNilIsValid(t *testing.T)

func TestValidatorInt8PNot

func TestValidatorInt8PNot(t *testing.T)

func TestValidatorInt8PPassingInvalid

func TestValidatorInt8PPassingInvalid(t *testing.T)

func TestValidatorInt8PPassingValid

func TestValidatorInt8PPassingValid(t *testing.T)

func TestValidatorInt8PZeroInvalid

func TestValidatorInt8PZeroInvalid(t *testing.T)

func TestValidatorInt8PZeroOrNilInvalid

func TestValidatorInt8PZeroOrNilInvalid(t *testing.T)

func TestValidatorInt8PZeroOrNilValid

func TestValidatorInt8PZeroOrNilValid(t *testing.T)

func TestValidatorInt8PZeroValid

func TestValidatorInt8PZeroValid(t *testing.T)

func TestValidatorInt8PassingInvalid

func TestValidatorInt8PassingInvalid(t *testing.T)

func TestValidatorInt8PassingValid

func TestValidatorInt8PassingValid(t *testing.T)

func TestValidatorInt8ZeroInvalid

func TestValidatorInt8ZeroInvalid(t *testing.T)

func TestValidatorInt8ZeroValid

func TestValidatorInt8ZeroValid(t *testing.T)

func TestValidatorIntBetweenInvalid

func TestValidatorIntBetweenInvalid(t *testing.T)

func TestValidatorIntBetweenValid

func TestValidatorIntBetweenValid(t *testing.T)

func TestValidatorIntEqualToInvalid

func TestValidatorIntEqualToInvalid(t *testing.T)

func TestValidatorIntEqualToValid

func TestValidatorIntEqualToValid(t *testing.T)

func TestValidatorIntGreaterOrEqualToInvalid

func TestValidatorIntGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorIntGreaterOrEqualToValid

func TestValidatorIntGreaterOrEqualToValid(t *testing.T)

func TestValidatorIntGreaterThanInvalid

func TestValidatorIntGreaterThanInvalid(t *testing.T)

func TestValidatorIntGreaterThanValid

func TestValidatorIntGreaterThanValid(t *testing.T)

func TestValidatorIntInSliceInvalid

func TestValidatorIntInSliceInvalid(t *testing.T)

func TestValidatorIntInSliceValid

func TestValidatorIntInSliceValid(t *testing.T)

func TestValidatorIntLessOrEqualToInvalid

func TestValidatorIntLessOrEqualToInvalid(t *testing.T)

func TestValidatorIntLessOrEqualToValid

func TestValidatorIntLessOrEqualToValid(t *testing.T)

func TestValidatorIntLessThanInvalid

func TestValidatorIntLessThanInvalid(t *testing.T)

func TestValidatorIntLessThanValid

func TestValidatorIntLessThanValid(t *testing.T)

func TestValidatorIntNot

func TestValidatorIntNot(t *testing.T)

func TestValidatorIntPBetweenInvalid

func TestValidatorIntPBetweenInvalid(t *testing.T)

func TestValidatorIntPBetweenValid

func TestValidatorIntPBetweenValid(t *testing.T)

func TestValidatorIntPEqualToInvalid

func TestValidatorIntPEqualToInvalid(t *testing.T)

func TestValidatorIntPEqualToValid

func TestValidatorIntPEqualToValid(t *testing.T)

func TestValidatorIntPGreaterOrEqualToInvalid

func TestValidatorIntPGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorIntPGreaterOrEqualToValid

func TestValidatorIntPGreaterOrEqualToValid(t *testing.T)

func TestValidatorIntPGreaterThanInvalid

func TestValidatorIntPGreaterThanInvalid(t *testing.T)

func TestValidatorIntPGreaterThanValid

func TestValidatorIntPGreaterThanValid(t *testing.T)

func TestValidatorIntPInSliceInvalid

func TestValidatorIntPInSliceInvalid(t *testing.T)

func TestValidatorIntPInSliceValid

func TestValidatorIntPInSliceValid(t *testing.T)

func TestValidatorIntPLessOrEqualToInvalid

func TestValidatorIntPLessOrEqualToInvalid(t *testing.T)

func TestValidatorIntPLessOrEqualToValid

func TestValidatorIntPLessOrEqualToValid(t *testing.T)

func TestValidatorIntPLessThanInvalid

func TestValidatorIntPLessThanInvalid(t *testing.T)

func TestValidatorIntPLessThanValid

func TestValidatorIntPLessThanValid(t *testing.T)

func TestValidatorIntPNilIsInvalid

func TestValidatorIntPNilIsInvalid(t *testing.T)

func TestValidatorIntPNilIsValid

func TestValidatorIntPNilIsValid(t *testing.T)

func TestValidatorIntPNot

func TestValidatorIntPNot(t *testing.T)

func TestValidatorIntPPassingInvalid

func TestValidatorIntPPassingInvalid(t *testing.T)

func TestValidatorIntPPassingValid

func TestValidatorIntPPassingValid(t *testing.T)

func TestValidatorIntPZeroInvalid

func TestValidatorIntPZeroInvalid(t *testing.T)

func TestValidatorIntPZeroOrNilInvalid

func TestValidatorIntPZeroOrNilInvalid(t *testing.T)

func TestValidatorIntPZeroOrNilValid

func TestValidatorIntPZeroOrNilValid(t *testing.T)

func TestValidatorIntPZeroValid

func TestValidatorIntPZeroValid(t *testing.T)

func TestValidatorIntPassingInvalid

func TestValidatorIntPassingInvalid(t *testing.T)

func TestValidatorIntPassingValid

func TestValidatorIntPassingValid(t *testing.T)

func TestValidatorIntZeroInvalid

func TestValidatorIntZeroInvalid(t *testing.T)

func TestValidatorIntZeroValid

func TestValidatorIntZeroValid(t *testing.T)

func TestValidatorRuneBetweenInvalid

func TestValidatorRuneBetweenInvalid(t *testing.T)

func TestValidatorRuneBetweenValid

func TestValidatorRuneBetweenValid(t *testing.T)

func TestValidatorRuneEqualToInvalid

func TestValidatorRuneEqualToInvalid(t *testing.T)

func TestValidatorRuneEqualToValid

func TestValidatorRuneEqualToValid(t *testing.T)

func TestValidatorRuneGreaterOrEqualToInvalid

func TestValidatorRuneGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorRuneGreaterOrEqualToValid

func TestValidatorRuneGreaterOrEqualToValid(t *testing.T)

func TestValidatorRuneGreaterThanInvalid

func TestValidatorRuneGreaterThanInvalid(t *testing.T)

func TestValidatorRuneGreaterThanValid

func TestValidatorRuneGreaterThanValid(t *testing.T)

func TestValidatorRuneInSliceInvalid

func TestValidatorRuneInSliceInvalid(t *testing.T)

func TestValidatorRuneInSliceValid

func TestValidatorRuneInSliceValid(t *testing.T)

func TestValidatorRuneLessOrEqualToInvalid

func TestValidatorRuneLessOrEqualToInvalid(t *testing.T)

func TestValidatorRuneLessOrEqualToValid

func TestValidatorRuneLessOrEqualToValid(t *testing.T)

func TestValidatorRuneLessThanInvalid

func TestValidatorRuneLessThanInvalid(t *testing.T)

func TestValidatorRuneLessThanValid

func TestValidatorRuneLessThanValid(t *testing.T)

func TestValidatorRuneNot

func TestValidatorRuneNot(t *testing.T)

func TestValidatorRunePBetweenInvalid

func TestValidatorRunePBetweenInvalid(t *testing.T)

func TestValidatorRunePBetweenValid

func TestValidatorRunePBetweenValid(t *testing.T)

func TestValidatorRunePEqualToInvalid

func TestValidatorRunePEqualToInvalid(t *testing.T)

func TestValidatorRunePEqualToValid

func TestValidatorRunePEqualToValid(t *testing.T)

func TestValidatorRunePGreaterOrEqualToInvalid

func TestValidatorRunePGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorRunePGreaterOrEqualToValid

func TestValidatorRunePGreaterOrEqualToValid(t *testing.T)

func TestValidatorRunePGreaterThanInvalid

func TestValidatorRunePGreaterThanInvalid(t *testing.T)

func TestValidatorRunePGreaterThanValid

func TestValidatorRunePGreaterThanValid(t *testing.T)

func TestValidatorRunePInSliceInvalid

func TestValidatorRunePInSliceInvalid(t *testing.T)

func TestValidatorRunePInSliceValid

func TestValidatorRunePInSliceValid(t *testing.T)

func TestValidatorRunePLessOrEqualToInvalid

func TestValidatorRunePLessOrEqualToInvalid(t *testing.T)

func TestValidatorRunePLessOrEqualToValid

func TestValidatorRunePLessOrEqualToValid(t *testing.T)

func TestValidatorRunePLessThanInvalid

func TestValidatorRunePLessThanInvalid(t *testing.T)

func TestValidatorRunePLessThanValid

func TestValidatorRunePLessThanValid(t *testing.T)

func TestValidatorRunePNilIsInvalid

func TestValidatorRunePNilIsInvalid(t *testing.T)

func TestValidatorRunePNilIsValid

func TestValidatorRunePNilIsValid(t *testing.T)

func TestValidatorRunePNot

func TestValidatorRunePNot(t *testing.T)

func TestValidatorRunePPassingInvalid

func TestValidatorRunePPassingInvalid(t *testing.T)

func TestValidatorRunePPassingValid

func TestValidatorRunePPassingValid(t *testing.T)

func TestValidatorRunePZeroInvalid

func TestValidatorRunePZeroInvalid(t *testing.T)

func TestValidatorRunePZeroOrNilInvalid

func TestValidatorRunePZeroOrNilInvalid(t *testing.T)

func TestValidatorRunePZeroOrNilValid

func TestValidatorRunePZeroOrNilValid(t *testing.T)

func TestValidatorRunePZeroValid

func TestValidatorRunePZeroValid(t *testing.T)

func TestValidatorRunePassingInvalid

func TestValidatorRunePassingInvalid(t *testing.T)

func TestValidatorRunePassingValid

func TestValidatorRunePassingValid(t *testing.T)

func TestValidatorRuneZeroInvalid

func TestValidatorRuneZeroInvalid(t *testing.T)

func TestValidatorRuneZeroValid

func TestValidatorRuneZeroValid(t *testing.T)

func TestValidatorUint16BetweenInvalid

func TestValidatorUint16BetweenInvalid(t *testing.T)

func TestValidatorUint16BetweenValid

func TestValidatorUint16BetweenValid(t *testing.T)

func TestValidatorUint16EqualToInvalid

func TestValidatorUint16EqualToInvalid(t *testing.T)

func TestValidatorUint16EqualToValid

func TestValidatorUint16EqualToValid(t *testing.T)

func TestValidatorUint16GreaterOrEqualToInvalid

func TestValidatorUint16GreaterOrEqualToInvalid(t *testing.T)

func TestValidatorUint16GreaterOrEqualToValid

func TestValidatorUint16GreaterOrEqualToValid(t *testing.T)

func TestValidatorUint16GreaterThanInvalid

func TestValidatorUint16GreaterThanInvalid(t *testing.T)

func TestValidatorUint16GreaterThanValid

func TestValidatorUint16GreaterThanValid(t *testing.T)

func TestValidatorUint16InSliceInvalid

func TestValidatorUint16InSliceInvalid(t *testing.T)

func TestValidatorUint16InSliceValid

func TestValidatorUint16InSliceValid(t *testing.T)

func TestValidatorUint16LessOrEqualToInvalid

func TestValidatorUint16LessOrEqualToInvalid(t *testing.T)

func TestValidatorUint16LessOrEqualToValid

func TestValidatorUint16LessOrEqualToValid(t *testing.T)

func TestValidatorUint16LessThanInvalid

func TestValidatorUint16LessThanInvalid(t *testing.T)

func TestValidatorUint16LessThanValid

func TestValidatorUint16LessThanValid(t *testing.T)

func TestValidatorUint16Not

func TestValidatorUint16Not(t *testing.T)

func TestValidatorUint16PBetweenInvalid

func TestValidatorUint16PBetweenInvalid(t *testing.T)

func TestValidatorUint16PBetweenValid

func TestValidatorUint16PBetweenValid(t *testing.T)

func TestValidatorUint16PEqualToInvalid

func TestValidatorUint16PEqualToInvalid(t *testing.T)

func TestValidatorUint16PEqualToValid

func TestValidatorUint16PEqualToValid(t *testing.T)

func TestValidatorUint16PGreaterOrEqualToInvalid

func TestValidatorUint16PGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorUint16PGreaterOrEqualToValid

func TestValidatorUint16PGreaterOrEqualToValid(t *testing.T)

func TestValidatorUint16PGreaterThanInvalid

func TestValidatorUint16PGreaterThanInvalid(t *testing.T)

func TestValidatorUint16PGreaterThanValid

func TestValidatorUint16PGreaterThanValid(t *testing.T)

func TestValidatorUint16PInSliceInvalid

func TestValidatorUint16PInSliceInvalid(t *testing.T)

func TestValidatorUint16PInSliceValid

func TestValidatorUint16PInSliceValid(t *testing.T)

func TestValidatorUint16PLessOrEqualToInvalid

func TestValidatorUint16PLessOrEqualToInvalid(t *testing.T)

func TestValidatorUint16PLessOrEqualToValid

func TestValidatorUint16PLessOrEqualToValid(t *testing.T)

func TestValidatorUint16PLessThanInvalid

func TestValidatorUint16PLessThanInvalid(t *testing.T)

func TestValidatorUint16PLessThanValid

func TestValidatorUint16PLessThanValid(t *testing.T)

func TestValidatorUint16PNilIsInvalid

func TestValidatorUint16PNilIsInvalid(t *testing.T)

func TestValidatorUint16PNilIsValid

func TestValidatorUint16PNilIsValid(t *testing.T)

func TestValidatorUint16PNot

func TestValidatorUint16PNot(t *testing.T)

func TestValidatorUint16PPassingInvalid

func TestValidatorUint16PPassingInvalid(t *testing.T)

func TestValidatorUint16PPassingValid

func TestValidatorUint16PPassingValid(t *testing.T)

func TestValidatorUint16PZeroInvalid

func TestValidatorUint16PZeroInvalid(t *testing.T)

func TestValidatorUint16PZeroOrNilInvalid

func TestValidatorUint16PZeroOrNilInvalid(t *testing.T)

func TestValidatorUint16PZeroOrNilValid

func TestValidatorUint16PZeroOrNilValid(t *testing.T)

func TestValidatorUint16PZeroValid

func TestValidatorUint16PZeroValid(t *testing.T)

func TestValidatorUint16PassingInvalid

func TestValidatorUint16PassingInvalid(t *testing.T)

func TestValidatorUint16PassingValid

func TestValidatorUint16PassingValid(t *testing.T)

func TestValidatorUint16ZeroInvalid

func TestValidatorUint16ZeroInvalid(t *testing.T)

func TestValidatorUint16ZeroValid

func TestValidatorUint16ZeroValid(t *testing.T)

func TestValidatorUint32BetweenInvalid

func TestValidatorUint32BetweenInvalid(t *testing.T)

func TestValidatorUint32BetweenValid

func TestValidatorUint32BetweenValid(t *testing.T)

func TestValidatorUint32EqualToInvalid

func TestValidatorUint32EqualToInvalid(t *testing.T)

func TestValidatorUint32EqualToValid

func TestValidatorUint32EqualToValid(t *testing.T)

func TestValidatorUint32GreaterOrEqualToInvalid

func TestValidatorUint32GreaterOrEqualToInvalid(t *testing.T)

func TestValidatorUint32GreaterOrEqualToValid

func TestValidatorUint32GreaterOrEqualToValid(t *testing.T)

func TestValidatorUint32GreaterThanInvalid

func TestValidatorUint32GreaterThanInvalid(t *testing.T)

func TestValidatorUint32GreaterThanValid

func TestValidatorUint32GreaterThanValid(t *testing.T)

func TestValidatorUint32InSliceInvalid

func TestValidatorUint32InSliceInvalid(t *testing.T)

func TestValidatorUint32InSliceValid

func TestValidatorUint32InSliceValid(t *testing.T)

func TestValidatorUint32LessOrEqualToInvalid

func TestValidatorUint32LessOrEqualToInvalid(t *testing.T)

func TestValidatorUint32LessOrEqualToValid

func TestValidatorUint32LessOrEqualToValid(t *testing.T)

func TestValidatorUint32LessThanInvalid

func TestValidatorUint32LessThanInvalid(t *testing.T)

func TestValidatorUint32LessThanValid

func TestValidatorUint32LessThanValid(t *testing.T)

func TestValidatorUint32Not

func TestValidatorUint32Not(t *testing.T)

func TestValidatorUint32PBetweenInvalid

func TestValidatorUint32PBetweenInvalid(t *testing.T)

func TestValidatorUint32PBetweenValid

func TestValidatorUint32PBetweenValid(t *testing.T)

func TestValidatorUint32PEqualToInvalid

func TestValidatorUint32PEqualToInvalid(t *testing.T)

func TestValidatorUint32PEqualToValid

func TestValidatorUint32PEqualToValid(t *testing.T)

func TestValidatorUint32PGreaterOrEqualToInvalid

func TestValidatorUint32PGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorUint32PGreaterOrEqualToValid

func TestValidatorUint32PGreaterOrEqualToValid(t *testing.T)

func TestValidatorUint32PGreaterThanInvalid

func TestValidatorUint32PGreaterThanInvalid(t *testing.T)

func TestValidatorUint32PGreaterThanValid

func TestValidatorUint32PGreaterThanValid(t *testing.T)

func TestValidatorUint32PInSliceInvalid

func TestValidatorUint32PInSliceInvalid(t *testing.T)

func TestValidatorUint32PInSliceValid

func TestValidatorUint32PInSliceValid(t *testing.T)

func TestValidatorUint32PLessOrEqualToInvalid

func TestValidatorUint32PLessOrEqualToInvalid(t *testing.T)

func TestValidatorUint32PLessOrEqualToValid

func TestValidatorUint32PLessOrEqualToValid(t *testing.T)

func TestValidatorUint32PLessThanInvalid

func TestValidatorUint32PLessThanInvalid(t *testing.T)

func TestValidatorUint32PLessThanValid

func TestValidatorUint32PLessThanValid(t *testing.T)

func TestValidatorUint32PNilIsInvalid

func TestValidatorUint32PNilIsInvalid(t *testing.T)

func TestValidatorUint32PNilIsValid

func TestValidatorUint32PNilIsValid(t *testing.T)

func TestValidatorUint32PNot

func TestValidatorUint32PNot(t *testing.T)

func TestValidatorUint32PPassingInvalid

func TestValidatorUint32PPassingInvalid(t *testing.T)

func TestValidatorUint32PPassingValid

func TestValidatorUint32PPassingValid(t *testing.T)

func TestValidatorUint32PZeroInvalid

func TestValidatorUint32PZeroInvalid(t *testing.T)

func TestValidatorUint32PZeroOrNilInvalid

func TestValidatorUint32PZeroOrNilInvalid(t *testing.T)

func TestValidatorUint32PZeroOrNilValid

func TestValidatorUint32PZeroOrNilValid(t *testing.T)

func TestValidatorUint32PZeroValid

func TestValidatorUint32PZeroValid(t *testing.T)

func TestValidatorUint32PassingInvalid

func TestValidatorUint32PassingInvalid(t *testing.T)

func TestValidatorUint32PassingValid

func TestValidatorUint32PassingValid(t *testing.T)

func TestValidatorUint32ZeroInvalid

func TestValidatorUint32ZeroInvalid(t *testing.T)

func TestValidatorUint32ZeroValid

func TestValidatorUint32ZeroValid(t *testing.T)

func TestValidatorUint64BetweenInvalid

func TestValidatorUint64BetweenInvalid(t *testing.T)

func TestValidatorUint64BetweenValid

func TestValidatorUint64BetweenValid(t *testing.T)

func TestValidatorUint64EqualToInvalid

func TestValidatorUint64EqualToInvalid(t *testing.T)

func TestValidatorUint64EqualToValid

func TestValidatorUint64EqualToValid(t *testing.T)

func TestValidatorUint64GreaterOrEqualToInvalid

func TestValidatorUint64GreaterOrEqualToInvalid(t *testing.T)

func TestValidatorUint64GreaterOrEqualToValid

func TestValidatorUint64GreaterOrEqualToValid(t *testing.T)

func TestValidatorUint64GreaterThanInvalid

func TestValidatorUint64GreaterThanInvalid(t *testing.T)

func TestValidatorUint64GreaterThanValid

func TestValidatorUint64GreaterThanValid(t *testing.T)

func TestValidatorUint64InSliceInvalid

func TestValidatorUint64InSliceInvalid(t *testing.T)

func TestValidatorUint64InSliceValid

func TestValidatorUint64InSliceValid(t *testing.T)

func TestValidatorUint64LessOrEqualToInvalid

func TestValidatorUint64LessOrEqualToInvalid(t *testing.T)

func TestValidatorUint64LessOrEqualToValid

func TestValidatorUint64LessOrEqualToValid(t *testing.T)

func TestValidatorUint64LessThanInvalid

func TestValidatorUint64LessThanInvalid(t *testing.T)

func TestValidatorUint64LessThanValid

func TestValidatorUint64LessThanValid(t *testing.T)

func TestValidatorUint64Not

func TestValidatorUint64Not(t *testing.T)

func TestValidatorUint64PBetweenInvalid

func TestValidatorUint64PBetweenInvalid(t *testing.T)

func TestValidatorUint64PBetweenValid

func TestValidatorUint64PBetweenValid(t *testing.T)

func TestValidatorUint64PEqualToInvalid

func TestValidatorUint64PEqualToInvalid(t *testing.T)

func TestValidatorUint64PEqualToValid

func TestValidatorUint64PEqualToValid(t *testing.T)

func TestValidatorUint64PGreaterOrEqualToInvalid

func TestValidatorUint64PGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorUint64PGreaterOrEqualToValid

func TestValidatorUint64PGreaterOrEqualToValid(t *testing.T)

func TestValidatorUint64PGreaterThanInvalid

func TestValidatorUint64PGreaterThanInvalid(t *testing.T)

func TestValidatorUint64PGreaterThanValid

func TestValidatorUint64PGreaterThanValid(t *testing.T)

func TestValidatorUint64PInSliceInvalid

func TestValidatorUint64PInSliceInvalid(t *testing.T)

func TestValidatorUint64PInSliceValid

func TestValidatorUint64PInSliceValid(t *testing.T)

func TestValidatorUint64PLessOrEqualToInvalid

func TestValidatorUint64PLessOrEqualToInvalid(t *testing.T)

func TestValidatorUint64PLessOrEqualToValid

func TestValidatorUint64PLessOrEqualToValid(t *testing.T)

func TestValidatorUint64PLessThanInvalid

func TestValidatorUint64PLessThanInvalid(t *testing.T)

func TestValidatorUint64PLessThanValid

func TestValidatorUint64PLessThanValid(t *testing.T)

func TestValidatorUint64PNilIsInvalid

func TestValidatorUint64PNilIsInvalid(t *testing.T)

func TestValidatorUint64PNilIsValid

func TestValidatorUint64PNilIsValid(t *testing.T)

func TestValidatorUint64PNot

func TestValidatorUint64PNot(t *testing.T)

func TestValidatorUint64PPassingInvalid

func TestValidatorUint64PPassingInvalid(t *testing.T)

func TestValidatorUint64PPassingValid

func TestValidatorUint64PPassingValid(t *testing.T)

func TestValidatorUint64PZeroInvalid

func TestValidatorUint64PZeroInvalid(t *testing.T)

func TestValidatorUint64PZeroOrNilInvalid

func TestValidatorUint64PZeroOrNilInvalid(t *testing.T)

func TestValidatorUint64PZeroOrNilValid

func TestValidatorUint64PZeroOrNilValid(t *testing.T)

func TestValidatorUint64PZeroValid

func TestValidatorUint64PZeroValid(t *testing.T)

func TestValidatorUint64PassingInvalid

func TestValidatorUint64PassingInvalid(t *testing.T)

func TestValidatorUint64PassingValid

func TestValidatorUint64PassingValid(t *testing.T)

func TestValidatorUint64ZeroInvalid

func TestValidatorUint64ZeroInvalid(t *testing.T)

func TestValidatorUint64ZeroValid

func TestValidatorUint64ZeroValid(t *testing.T)

func TestValidatorUint8BetweenInvalid

func TestValidatorUint8BetweenInvalid(t *testing.T)

func TestValidatorUint8BetweenValid

func TestValidatorUint8BetweenValid(t *testing.T)

func TestValidatorUint8EqualToInvalid

func TestValidatorUint8EqualToInvalid(t *testing.T)

func TestValidatorUint8EqualToValid

func TestValidatorUint8EqualToValid(t *testing.T)

func TestValidatorUint8GreaterOrEqualToInvalid

func TestValidatorUint8GreaterOrEqualToInvalid(t *testing.T)

func TestValidatorUint8GreaterOrEqualToValid

func TestValidatorUint8GreaterOrEqualToValid(t *testing.T)

func TestValidatorUint8GreaterThanInvalid

func TestValidatorUint8GreaterThanInvalid(t *testing.T)

func TestValidatorUint8GreaterThanValid

func TestValidatorUint8GreaterThanValid(t *testing.T)

func TestValidatorUint8InSliceInvalid

func TestValidatorUint8InSliceInvalid(t *testing.T)

func TestValidatorUint8InSliceValid

func TestValidatorUint8InSliceValid(t *testing.T)

func TestValidatorUint8LessOrEqualToInvalid

func TestValidatorUint8LessOrEqualToInvalid(t *testing.T)

func TestValidatorUint8LessOrEqualToValid

func TestValidatorUint8LessOrEqualToValid(t *testing.T)

func TestValidatorUint8LessThanInvalid

func TestValidatorUint8LessThanInvalid(t *testing.T)

func TestValidatorUint8LessThanValid

func TestValidatorUint8LessThanValid(t *testing.T)

func TestValidatorUint8Not

func TestValidatorUint8Not(t *testing.T)

func TestValidatorUint8PBetweenInvalid

func TestValidatorUint8PBetweenInvalid(t *testing.T)

func TestValidatorUint8PBetweenValid

func TestValidatorUint8PBetweenValid(t *testing.T)

func TestValidatorUint8PEqualToInvalid

func TestValidatorUint8PEqualToInvalid(t *testing.T)

func TestValidatorUint8PEqualToValid

func TestValidatorUint8PEqualToValid(t *testing.T)

func TestValidatorUint8PGreaterOrEqualToInvalid

func TestValidatorUint8PGreaterOrEqualToInvalid(t *testing.T)

func TestValidatorUint8PGreaterOrEqualToValid

func TestValidatorUint8PGreaterOrEqualToValid(t *testing.T)

func TestValidatorUint8PGreaterThanInvalid

func TestValidatorUint8PGreaterThanInvalid(t *testing.T)

func TestValidatorUint8PGreaterThanValid

func TestValidatorUint8PGreaterThanValid(t *testing.T)

func TestValidatorUint8PInSliceInvalid

func TestValidatorUint8PInSliceInvalid(t *testing.T)

func TestValidatorUint8PInSliceValid

func TestValidatorUint8PInSliceValid(t *testing.T)

func TestValidatorUint8PLessOrEqualToInvalid

func TestValidatorUint8PLessOrEqualToInvalid(t *testing.T)

func TestValidatorUint8PLessOrEqualToValid

func TestValidatorUint8PLessOrEqualToValid(t *testing.T)

func TestValidatorUint8PLessThanInvalid

func TestValidatorUint8PLessThanInvalid(t *testing.T)

func TestValidatorUint8PLessThanValid

func TestValidatorUint8PLessThanValid(t *testing.T)

func TestValidatorUint8PNilIsInvalid

func TestValidatorUint8PNilIsInvalid(t *testing.T)

func TestValidatorUint8PNilIsValid

func TestValidatorUint8PNilIsValid(t *testing.T)

func TestValidatorUint8PNot

func TestValidatorUint8PNot(t *testing.T)

func TestValidatorUint8PPassingInvalid

func TestValidatorUint8PPassingInvalid(t *testing.T)

func TestValidatorUint8PPassingValid

func TestValidatorUint8PPassingValid(t *testing.T)

func TestValidatorUint8PZeroInvalid

func TestValidatorUint8PZeroInvalid(t *testing.T)

func TestValidatorUint8PZeroOrNilInvalid

func TestValidatorUint8PZeroOrNilInvalid(t *testing.T)

func TestValidatorUint8PZeroOrNilValid

func TestValidatorUint8PZeroOrNilValid(t *testing.T)

func TestValidatorUint8PZeroValid

func TestValidatorUint8PZeroValid(t *testing.T)

func TestValidatorUint8PassingInvalid

func TestValidatorUint8PassingInvalid(t *testing.T)

func TestValidatorUint8PassingValid

func TestValidatorUint8PassingValid(t *testing.T)

func TestValidatorUint8ZeroInvalid

func TestValidatorUint8ZeroInvalid(t *testing.T)

func TestValidatorUint8ZeroValid

func TestValidatorUint8ZeroValid(t *testing.T)

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Implementation of the Go error interface in Valgo. The [Validation.Error()] method returns a value of this type.

There is a function in this type, [Errors()], that returns a list of errors in a Validation session.

func (*Error) Error

func (e *Error) Error() string

Return the error message associated with a Valgo error.

func (*Error) Errors

func (e *Error) Errors() map[string]*valueError

Return a map with each Invalid value error.

func (*Error) MarshalJSON

func (e *Error) MarshalJSON() ([]byte, error)

Return the JSON encoding of the validation error messages.

A custom function can be set with [SetMarshalJson()]

type FactoryOptions

type FactoryOptions struct {
	// A string field that represents the default locale code to use by the
	// factory if a specific locale code is not provided when a Validation is
	// created
	LocaleCodeDefault string
	// A map field that allows to modify the current or add new locales
	Locales map[string]*Locale
	// A function field that allows to set a custom JSON marshaler for [Error]
	MarshalJsonFunc func(e *Error) ([]byte, error)
}

FactoryOptions is a struct in Go that is used to pass options to a [Factory()]

type Locale

type Locale map[string]string

Locale is a type alias that represents a map of locale entries. The keys in the map are strings that represent the entry's identifier, and the values are strings that contain the corresponding localized text for that entry

type Options

type Options struct {

	// A string field that represents the locale code to use by the [Validation]
	// session
	LocaleCode string
	// A map field that allows to modify or add a new [Locale]
	Locale *Locale
	// A function field that allows to set a custom JSON marshaler for [Error]
	MarshalJsonFunc func(e *Error) ([]byte, error)
	// contains filtered or unexported fields
}

type TypeNumber

type TypeNumber interface {
	~int |
		~int8 |
		~int16 |
		~int32 |
		~int64 |
		~uint |
		~uint8 |
		~uint16 |
		~uint32 |
		~uint64 |
		~float32 |
		~float64
}

Custom generic type covering all numeric types. This type is used as the value type in ValidatorNumber and ValidatorNumberP.

type Validation

type Validation struct {
	// contains filtered or unexported fields
}

The Validation session in Valgo is the main structure for validating one or more values. It is called Validation in code.

A Validation session will contain one or more Validators, where each Validator will have the responsibility to validate a value with one or more rules.

There are multiple functions to create a Validation session, depending on the requirements:

the function Is(...) is likely to be the most frequently used function in your validations. When Is(...) is called, the function creates a validation and receives a validator at the same time.

func AddErrorMessage

func AddErrorMessage(name string, message string) *Validation

Create a new Validation session and add an error message to it without executing a field validator. By adding this error message, the Validation session will be marked as invalid.

func Check

func Check(v Validator) *Validation

The Check(...) function is similar to the Is(...) function, however with Check(...)` the Rules of the Validator parameter are not short-circuited, which means that regardless of whether a previous rule was valid, all rules are checked.

This example shows two rules that fail due to the empty value in the full_name Validator, and since the Validator is not short-circuited, both error messages are added to the error result.

Example
val := Check(String("", "full_name").Not().Blank().OfLengthBetween(4, 20))

if !val.Valid() {
	out, _ := json.MarshalIndent(val.Error(), "", "  ")
	fmt.Println(string(out))
}
Output:

{
  "full_name": [
    "Full name can't be blank",
    "Full name must have a length between \"4\" and \"20\""
  ]
}

func In

func In(name string, v *Validation) *Validation

The In(...) function executes one or more validators in a namespace, so the value names in the error result are prefixed with this namespace. This is useful for validating nested structures.

In the following example we are validating the Person and the nested Address structure. We can distinguish the errors of the nested Address structure in the error results.

Example
type Address struct {
	Name   string
	Street string
}

type Person struct {
	Name    string
	Address Address
}

p := Person{"Bob", Address{"", "1600 Amphitheatre Pkwy"}}

val := Is(String(p.Name, "name").OfLengthBetween(4, 20)).
	In("address", Is(
		String(p.Address.Name, "name").Not().Blank()).Is(
		String(p.Address.Street, "street").Not().Blank()))

if !val.Valid() {
	out, _ := json.MarshalIndent(val.Error(), "", "  ")
	fmt.Println(string(out))
}
Output:

{
  "address.name": [
    "Name can't be blank"
  ],
  "name": [
    "Name must have a length between \"4\" and \"20\""
  ]
}

func InRow

func InRow(name string, index int, v *Validation) *Validation

The InRow(...) function executes one or more validators in a namespace similar to the In(...) function, but with indexed namespace. So, the value names in the error result are prefixed with this indexed namespace. It is useful for validating nested lists in structures.

In the following example we validate the Person and the nested list Addresses. The error results can distinguish the errors of the nested list Addresses.

Example
type Address struct {
	Name   string
	Street string
}

type Person struct {
	Name      string
	Addresses []Address
}

p := Person{
	"Bob",
	[]Address{
		{"", "1600 Amphitheatre Pkwy"},
		{"Home", ""},
	},
}

val := Is(String(p.Name, "name").OfLengthBetween(4, 20))

for i, a := range p.Addresses {
	val.InRow("addresses", i, Is(
		String(a.Name, "name").Not().Blank()).Is(
		String(a.Street, "street").Not().Blank()))
}

if !val.Valid() {
	out, _ := json.MarshalIndent(val.Error(), "", "  ")
	fmt.Println(string(out))
}
Output:

{
  "addresses[0].name": [
    "Name can't be blank"
  ],
  "addresses[1].street": [
    "Street can't be blank"
  ],
  "name": [
    "Name must have a length between \"4\" and \"20\""
  ]
}

func Is

func Is(v Validator) *Validation

The Is(...) function allows you to pass a Validator with the value and the rules for validating it. At the same time, create a Validation session, which lets you add more Validators in order to verify more values.

As shown in the following example, we are passing to the function Is(...) the Validator for the full_name value. The function returns a Validation session that allows us to add more Validators to validate more values; in the example case the values age and status:

Example
val := Is(String("Bob", "full_name").Not().Blank().OfLengthBetween(4, 20)).
	Is(Number(17, "age").GreaterThan(18)).
	Is(String("singl", "status").InSlice([]string{"married", "single"}))

if !val.Valid() {
	out, _ := json.MarshalIndent(val.Error(), "", "  ")
	fmt.Println(string(out))
}
Output:

{
  "age": [
    "Age must be greater than \"18\""
  ],
  "full_name": [
    "Full name must have a length between \"4\" and \"20\""
  ],
  "status": [
    "Status is not valid"
  ]
}

func New

func New(options ...Options) *Validation

This function allows you to create a new Validation session without a Validator. This is useful for conditional validation, reusing validation logic or just to pass optional parameters to the Validation session.

The function accepts an optional parameter of type Options struct, which allows you to specify options such as the specific locale code and locale to use, and a custom JSON marshaler for errors.

The following example conditionally adds a validator rule for the month_day value.

Example
month := 5
monthDay := 11

val := New()

if month == 6 {
	val.Is(Number(monthDay, "month_day").LessOrEqualTo(10))
}

if val.Valid() {
	fmt.Println("The validation passes")
}
Output:

The validation passes

func (*Validation) AddErrorMessage

func (v *Validation) AddErrorMessage(name string, message string) *Validation

Add an error message to the Validation session without executing a field validator. By adding this error message, the Validation session will be marked as invalid.

func (*Validation) Check

func (validation *Validation) Check(v Validator) *Validation

Add a field validator to a Validation session. But unlike [Is()] the field validator is not short-circuited.

func (*Validation) Error

func (validation *Validation) Error() error

Return a map with the information for each invalid field validator in the Validation session.

func (*Validation) Errors

func (session *Validation) Errors() map[string]*valueError

Return a map with the information for each invalid field validator in the Validation session.

func (*Validation) In

func (validation *Validation) In(name string, _validation *Validation) *Validation

Add a map namespace to a Validation session.

func (*Validation) InRow

func (validation *Validation) InRow(name string, index int, _validation *Validation) *Validation

Add an indexed namespace to a Validation session.

func (*Validation) Is

func (validation *Validation) Is(v Validator) *Validation

Add a field validator to a Validation session.

func (*Validation) IsValid

func (validation *Validation) IsValid(name string) bool

Return true if a specific field validator is valid.

Example
val := Is(Number(16, "age").GreaterThan(18)).
	Is(String("single", "status").InSlice([]string{"married", "single"}))

if !val.IsValid("age") {
	fmt.Println("Warning: someone underage is trying to sign up")
}
Output:

Warning: someone underage is trying to sign up

func (*Validation) Merge

func (validation *Validation) Merge(_validation *Validation) *Validation

Using [Merge](...) you can merge two Validation sessions. When two validations are merged, errors with the same value name will be merged. It is useful for reusing validation logic.

The following example merges the Validation session returned by the validatePreStatus function. Since both Validation sessions validate a value with the name status, the error returned will return two error messages, and without duplicate the Not().Blank() error message rule.

Example
type Record struct {
	Name   string
	Status string
}

validatePreStatus := func(status string) *Validation {
	regex, _ := regexp.Compile("pre-.+")

	return Check(String(status, "status").Not().Blank().MatchingTo(regex))
}

r := Record{"Classified", ""}

val := Is(
	String(r.Name, "name").Not().Blank()).Is(
	String(r.Status, "status").Not().Blank())

val.Merge(validatePreStatus(r.Status))

if !val.Valid() {
	out, _ := json.MarshalIndent(val.Error(), "", "  ")
	fmt.Println(string(out))
}
Output:

{
  "status": [
    "Status can't be blank",
    "Status must match to \"pre-.+\""
  ]
}

func (*Validation) MergeError

func (v *Validation) MergeError(err *Error) *Validation

MergeError allows merging Valgo errors from an already validated Validation session. The function takes an Valgo Error pointer as an argument and returns a Validation pointer.

func (*Validation) MergeErrorIn

func (v *Validation) MergeErrorIn(name string, err *Error) *Validation

MergeErrorIn allows merging Valgo errors from already validated Validation sessions within a map namespace. The function takes a namespace name and an Error pointer as arguments and returns a Validation pointer.

func (*Validation) MergeErrorInRow

func (v *Validation) MergeErrorInRow(name string, index int, err *Error) *Validation

MergeErrorInRow allows merging Valgo errors from already validated Validation sessions within an indexed namespace. The function takes a namespace name, an index, and an Error pointer as arguments and returns a Validation pointer.

func (*Validation) Valid

func (validation *Validation) Valid() bool

A Validation session provides this function which returns either true if all their validators are valid or false if any one of them is invalid.

In the following example, even though the Validator for age is valid, the Validator for status is invalid, making the entire Validator session invalid.

Example
val := Is(Number(21, "age").GreaterThan(18)).
	Is(String("singl", "status").InSlice([]string{"married", "single"}))

if !val.Valid() {
	out, _ := json.MarshalIndent(val.Error(), "", "  ")
	fmt.Println(string(out))
}
Output:

{
  "status": [
    "Status is not valid"
  ]
}

type ValidationFactory

type ValidationFactory struct {
	// contains filtered or unexported fields
}

func Factory

func Factory(options FactoryOptions) *ValidationFactory

Factory is a function used to create a Valgo factory.

With a Valgo factory, you can create Validation sessions with preset options, avoiding having to pass options each time when a Validation session is created.

This allows for more flexibility and easier management of options.

The Factory function accepts an options parameter of type FactoryOptions struct, which allows you to specify options such as the default locale code, available locales and a custom JSON marshaler for errors.

func (*ValidationFactory) AddErrorMessage

func (_factory *ValidationFactory) AddErrorMessage(name string, message string) *Validation

Create a new Validation session, through a factory, and add an error message to it without executing a field validator. By adding this error message, the Validation session will be marked as invalid.

func (*ValidationFactory) Check

func (_factory *ValidationFactory) Check(v Validator) *Validation

The Check function, through a factory, is similar to the Is function, however with Check the Rules of the Validator parameter are not short-circuited, which means that regardless of whether a previous rule was valid, all rules are checked.

The function is similar to the [Check()] function, but it uses a factory. For more information see the [Check()] function.

func (*ValidationFactory) In

func (_factory *ValidationFactory) In(name string, v *Validation) *Validation

The In function executes, through a factory, one or more validators in a namespace, so the value names in the error result are prefixed with this namespace. This is useful for validating nested structures.

The function is similar to the [In()] function, but it uses a factory. For more information see the [In()] function.

func (*ValidationFactory) InRow

func (_factory *ValidationFactory) InRow(name string, index int, v *Validation) *Validation

The InRow function executes, through a factory, one or more validators in a namespace similar to the In(...) function, but with indexed namespace. So,\ the value names in the error result are prefixed with this indexed namespace. It is useful for validating nested lists in structures.

The function is similar to the [InRow()] function, but it uses a factory. For more information see the [InRow()] function.

func (*ValidationFactory) Is

func (_factory *ValidationFactory) Is(v Validator) *Validation

The Is function allows you to pass, through a factory, a Validator with the value and the rules for validating it. At the same time, create a Validation session, which lets you add more Validators in order to verify more values.

The function is similar to the [Is()] function, but it uses a factory. For more information see the [Is()] function.

func (*ValidationFactory) New

func (_factory *ValidationFactory) New(options ...Options) *Validation

This New function allows you to create, through a factory, a new Validation session without a Validator. This is useful for conditional validation or reusing validation logic.

The function is similar to the [New()] function, but it uses a factory. For more information see the [New()] function.

type Validator

type Validator interface {
	Context() *ValidatorContext
}

Interface implemented by valgo Validators and custom Validators.

type ValidatorAny

type ValidatorAny struct {
	// contains filtered or unexported fields
}

The Any validator's type that keeps its validator context.

func Any

func Any(value any, nameAndTitle ...string) *ValidatorAny

Receive a value to validate.

The value can be any type;

Optionally, the function can receive a name and title, in that order, to be displayed in the error messages. A value_%N` pattern is used as a name in the error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name phone_number will be humanized as Phone Number.

func (*ValidatorAny) Context

func (validator *ValidatorAny) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorAny) EqualTo

func (validator *ValidatorAny) EqualTo(value any, template ...string) *ValidatorAny

Validate if a value is equal to another. This function internally uses the golang `==` operator. For example:

status := "running"
Is(v.Any(status).Equal("running"))

func (*ValidatorAny) Nil

func (validator *ValidatorAny) Nil(template ...string) *ValidatorAny

Validate if a value is nil. For example:

var status *string
Is(v.Any(status).Nil())

func (*ValidatorAny) Not

func (validator *ValidatorAny) Not() *ValidatorAny

Invert the logical value associated with the next validator function. For example:

// It will return false because `Not()` inverts the boolean value associated with the `Equal()` function
Is(v.Any("a").Not().Equal("a")).Valid()

func (*ValidatorAny) Passing

func (validator *ValidatorAny) Passing(function func(v any) bool, template ...string) *ValidatorAny

Validate if a value passes a custom function. For example:

status := ""
Is(v.Any(status).Passing((v any) bool {
	return v == getNewStatus()
})

type ValidatorBool

type ValidatorBool[T ~bool] struct {
	// contains filtered or unexported fields
}

The Boolean validator type that keeps its validator context.

func Bool

func Bool[T ~bool](value T, nameAndTitle ...string) *ValidatorBool[T]

func (*ValidatorBool[T]) Context

func (validator *ValidatorBool[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorBool[T]) EqualTo

func (validator *ValidatorBool[T]) EqualTo(value T, template ...string) *ValidatorBool[T]

Validate if a boolean value is equal to another. For example:

activated := true
Is(v.Bool(activated).Equal(true))

func (*ValidatorBool[T]) False

func (validator *ValidatorBool[T]) False(template ...string) *ValidatorBool[T]

Validate if a boolean value is false. For example:

activated := false
Is(v.Bool(activated).Equal(true)).Valid()

func (*ValidatorBool[T]) InSlice

func (validator *ValidatorBool[T]) InSlice(slice []T, template ...string) *ValidatorBool[T]

Validate if the value of a boolean pointer is present in a boolean slice. For example:

activated := false
elements := []bool{true, false, true}
Is(v.Bool(activated).InSlice(elements))

func (*ValidatorBool[T]) Not

func (validator *ValidatorBool[T]) Not() *ValidatorBool[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because `Not()` inverts the boolean value associated with the True() function
Is(v.Bool(true).Not().True()).Valid()

func (*ValidatorBool[T]) Passing

func (validator *ValidatorBool[T]) Passing(function func(v T) bool, template ...string) *ValidatorBool[T]

Validate if a boolean value pass a custom function. For example:

activated := false
Is(v.Bool(activated).Passing((v bool) bool {
	return v == someBoolFunction()
})

func (*ValidatorBool[T]) True

func (validator *ValidatorBool[T]) True(template ...string) *ValidatorBool[T]

Validate if a boolean value is true. For example:

activated := true
Is(v.Bool(activated).True())

type ValidatorBoolP

type ValidatorBoolP[T ~bool] struct {
	// contains filtered or unexported fields
}

The Boolean pointer validator type that keeps its validator context.

func BoolP

func BoolP[T ~bool](value *T, nameAndTitle ...string) *ValidatorBoolP[T]

Receives a boolean pointer to validate.

The value also can be a custom boolean type such as `type Active bool;`

Optionally, the function can receive a name and title, in that order, to be displayed in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorBoolP[T]) Context

func (validator *ValidatorBoolP[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorBoolP[T]) EqualTo

func (validator *ValidatorBoolP[T]) EqualTo(value T, template ...string) *ValidatorBoolP[T]

Validate if the value of a boolean pointer is equal to another value. For example:

activated := true
Is(v.BoolP(&activated).Equal(true))

func (*ValidatorBoolP[T]) False

func (validator *ValidatorBoolP[T]) False(template ...string) *ValidatorBoolP[T]

Validate if the value of a boolean pointer is false. For example:

activated := false
Is(v.BoolP(&activated).False())

func (*ValidatorBoolP[T]) FalseOrNil

func (validator *ValidatorBoolP[T]) FalseOrNil(template ...string) *ValidatorBoolP[T]

Validate if the value of a boolean pointer is false or nil. For example:

var activated *bool
Is(v.BoolP(activated).FalseOrNil())
*activated = false
Is(v.BoolP(activated).FalseOrNil())

func (*ValidatorBoolP[T]) InSlice

func (validator *ValidatorBoolP[T]) InSlice(slice []T, template ...string) *ValidatorBoolP[T]

Validate if the value of a boolean pointer is present in a boolean slice. For example:

activated := false
elements := []bool{true, false, true}
Is(v.BoolP(&activated).InSlice(elements))

func (*ValidatorBoolP[T]) Nil

func (validator *ValidatorBoolP[T]) Nil(template ...string) *ValidatorBoolP[T]

Validate if a boolean pointer is nil. For example:

var activated *bool
Is(v.BoolP(activated).Nil())

func (*ValidatorBoolP[T]) Not

func (validator *ValidatorBoolP[T]) Not() *ValidatorBoolP[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the True() function
activated := true
Is(v.BoolP(&activated).Not().True()).Valid()

func (*ValidatorBoolP[T]) Passing

func (validator *ValidatorBoolP[T]) Passing(function func(v *T) bool, template ...string) *ValidatorBoolP[T]

Validate if a boolean pointer pass a custom function. For example:

activated := false
Is(v.BoolP(&activated).Passing((v *bool) bool {
	return *v == someBoolFunction()
})

func (*ValidatorBoolP[T]) True

func (validator *ValidatorBoolP[T]) True(template ...string) *ValidatorBoolP[T]

Validate if the value of a boolean pointer is true. For example:

activated := true
Is(v.BoolP(&activated).True())

type ValidatorByte

type ValidatorByte[T ~byte] struct {
	// contains filtered or unexported fields
}

The byte validator type that keeps its validator context.

func Byte

func Byte[T ~byte](value T, nameAndTitle ...string) *ValidatorByte[T]

func (*ValidatorByte[T]) Between

func (validator *ValidatorByte[T]) Between(min T, max T, template ...string) *ValidatorByte[T]

Validate if the byte is within a range (inclusive). For example:

Is(v.Byte(byte(3)).Between(byte(2),byte(6)))

func (*ValidatorByte[T]) Context

func (validator *ValidatorByte[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorByte[T]) EqualTo

func (validator *ValidatorByte[T]) EqualTo(value T, template ...string) *ValidatorByte[T]

Validate if the byte value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := byte(2)
Is(v.Byte(quantity).Equal(byte(2)))

func (*ValidatorByte[T]) GreaterOrEqualTo

func (validator *ValidatorByte[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorByte[T]

Validate if the byte value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := byte(3)
Is(v.Byte(quantity).GreaterOrEqualTo(byte(3)))

func (*ValidatorByte[T]) GreaterThan

func (validator *ValidatorByte[T]) GreaterThan(value T, template ...string) *ValidatorByte[T]

Validate if the byte value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := byte(3)
Is(v.Byte(quantity).GreaterThan(byte(2)))

func (*ValidatorByte[T]) InSlice

func (validator *ValidatorByte[T]) InSlice(slice []T, template ...string) *ValidatorByte[T]

Validate if the byte value is present in the byte slice. For example:

quantity := byte(3)
validQuantities := []byte{1,3,5}
Is(v.Byte(quantity).InSlice(validQuantities))

func (*ValidatorByte[T]) LessOrEqualTo

func (validator *ValidatorByte[T]) LessOrEqualTo(value T, template ...string) *ValidatorByte[T]

Validate if the byte value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := byte(2)
Is(v.Byte(quantity).LessOrEqualTo(byte(2)))

func (*ValidatorByte[T]) LessThan

func (validator *ValidatorByte[T]) LessThan(value T, template ...string) *ValidatorByte[T]

Validate if the byte value is less than another. This function internally uses the golang `<` operator. For example:

quantity := byte(2)
Is(v.Byte(quantity).LessThan(byte(3)))

func (*ValidatorByte[T]) Not

func (validator *ValidatorByte[T]) Not() *ValidatorByte[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Byte(byte(0)).Not().Zero()).Valid()

func (*ValidatorByte[T]) Passing

func (validator *ValidatorByte[T]) Passing(function func(v T) bool, template ...string) *ValidatorByte[T]

Validate if the byte value passes a custom function. For example:

quantity := byte(2)
Is(v.Byte(quantity).Passing((v byte) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorByte[T]) Zero

func (validator *ValidatorByte[T]) Zero(template ...string) *ValidatorByte[T]

Validate if the byte value is zero.

For example:

Is(v.Byte(byte(0)).Zero())

type ValidatorByteP

type ValidatorByteP[T ~byte] struct {
	// contains filtered or unexported fields
}

The byte pointer validator type that keeps its validator context.

func ByteP

func ByteP[T ~byte](value *T, nameAndTitle ...string) *ValidatorByteP[T]

Receives the byte pointer to validate.

The value also can be a custom byte type such as `type Level *byte;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorByteP[T]) Between

func (validator *ValidatorByteP[T]) Between(min T, max T, template ...string) *ValidatorByteP[T]

Validate if the value of the byte pointer is within a range (inclusive). For example:

n := byte(3)
Is(v.ByteP(&n).Between(byte(2),byte(6)))

func (*ValidatorByteP[T]) Context

func (validator *ValidatorByteP[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorByteP[T]) EqualTo

func (validator *ValidatorByteP[T]) EqualTo(value T, template ...string) *ValidatorByteP[T]

Validate if the byte pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := byte(2)
Is(v.ByteP(quantity).Equal(byte(2)))

func (*ValidatorByteP[T]) GreaterOrEqualTo

func (validator *ValidatorByteP[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorByteP[T]

Validate if the byte pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := byte(3)
Is(v.ByteP(&quantity).GreaterOrEqualTo(byte(3)))

func (*ValidatorByteP[T]) GreaterThan

func (validator *ValidatorByteP[T]) GreaterThan(value T, template ...string) *ValidatorByteP[T]

Validate if the byte pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := byte(3)
Is(v.ByteP(&quantity).GreaterThan(byte(2)))

func (*ValidatorByteP[T]) InSlice

func (validator *ValidatorByteP[T]) InSlice(slice []T, template ...string) *ValidatorByteP[T]

Validate if the byte pointer value is present in a numeric slice. For example:

quantity := byte(3)
validQuantities := []byte{1,3,5}
Is(v.ByteP(&quantity).InSlice(validQuantities))

func (*ValidatorByteP[T]) LessOrEqualTo

func (validator *ValidatorByteP[T]) LessOrEqualTo(value T, template ...string) *ValidatorByteP[T]

Validate if the byte pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := byte(2)
Is(v.ByteP(&quantity).LessOrEqualTo(byte(2)))

func (*ValidatorByteP[T]) LessThan

func (validator *ValidatorByteP[T]) LessThan(value T, template ...string) *ValidatorByteP[T]

Validate if the byte pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := byte(2)
Is(v.ByteP(&quantity).LessThan(byte(3)))

func (*ValidatorByteP[T]) Nil

func (validator *ValidatorByteP[T]) Nil(template ...string) *ValidatorByteP[T]

Validate if the byte pointer value is nil.

For example:

var quantity *byte
Is(v.ByteP(quantity).Nil()) // Will be true

func (*ValidatorByteP[T]) Not

func (validator *ValidatorByteP[T]) Not() *ValidatorByteP[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := byte(0)
Is(v.ByteP(&n).Not().Zero()).Valid()

func (*ValidatorByteP[T]) Passing

func (validator *ValidatorByteP[T]) Passing(function func(v *T) bool, template ...string) *ValidatorByteP[T]

Validate if the byte pointer value passes a custom function. For example:

quantity := byte(2)
Is(v.ByteP(&quantity).Passing((v *byte) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorByteP[T]) Zero

func (validator *ValidatorByteP[T]) Zero(template ...string) *ValidatorByteP[T]

Validate if the byte pointer value is zero.

For example:

n := byte(0)
Is(v.ByteP(&n).Zero())

func (*ValidatorByteP[T]) ZeroOrNil

func (validator *ValidatorByteP[T]) ZeroOrNil(template ...string) *ValidatorByteP[T]

Validate if the byte pointer value is zero or nil.

For example:

var _quantity *byte
Is(v.ByteP(_quantity).ZeroOrNil()) // Will be true

type ValidatorContext

type ValidatorContext struct {
	// contains filtered or unexported fields
}

The context keeps the state and provides the functions to control a custom validator.

func NewContext

func NewContext(value any, nameAndTitle ...string) *ValidatorContext

Create a new ValidatorContext to be used by a custom validator.

func (*ValidatorContext) Add

func (ctx *ValidatorContext) Add(function func() bool, errorKey string, template ...string) *ValidatorContext

Add a function to a custom validator.

func (*ValidatorContext) AddWithParams

func (ctx *ValidatorContext) AddWithParams(function func() bool, errorKey string, templateParams map[string]any, template ...string) *ValidatorContext

Add a function to a custom validator and pass a map with values used for the validator function to be displayed in the error message.

func (*ValidatorContext) AddWithValue

func (ctx *ValidatorContext) AddWithValue(function func() bool, errorKey string, value any, template ...string) *ValidatorContext

Add a function to a custom validator and pass a value used for the validator function to be displayed in the error message.

Use [AddWithParams()] if the error message requires more input values.

func (*ValidatorContext) Not

func (ctx *ValidatorContext) Not() *ValidatorContext

Invert the boolean value associated with the next validator function in a custom validator.

func (*ValidatorContext) Value

func (ctx *ValidatorContext) Value() any

Return the value being validated in a custom validator.

type ValidatorFloat32

type ValidatorFloat32[T ~float32] struct {
	// contains filtered or unexported fields
}

The float32 validator type that keeps its validator context.

func Float32

func Float32[T ~float32](value T, nameAndTitle ...string) *ValidatorFloat32[T]

func (*ValidatorFloat32[T]) Between

func (validator *ValidatorFloat32[T]) Between(min T, max T, template ...string) *ValidatorFloat32[T]

Validate if the float32 is within a range (inclusive). For example:

Is(v.Float32(float32(3)).Between(float32(2),float32(6)))

func (*ValidatorFloat32[T]) Context

func (validator *ValidatorFloat32[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorFloat32[T]) EqualTo

func (validator *ValidatorFloat32[T]) EqualTo(value T, template ...string) *ValidatorFloat32[T]

Validate if the float32 value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := float32(2)
Is(v.Float32(quantity).Equal(float32(2)))

func (*ValidatorFloat32[T]) GreaterOrEqualTo

func (validator *ValidatorFloat32[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorFloat32[T]

Validate if the float32 value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := float32(3)
Is(v.Float32(quantity).GreaterOrEqualTo(float32(3)))

func (*ValidatorFloat32[T]) GreaterThan

func (validator *ValidatorFloat32[T]) GreaterThan(value T, template ...string) *ValidatorFloat32[T]

Validate if the float32 value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := float32(3)
Is(v.Float32(quantity).GreaterThan(float32(2)))

func (*ValidatorFloat32[T]) InSlice

func (validator *ValidatorFloat32[T]) InSlice(slice []T, template ...string) *ValidatorFloat32[T]

Validate if the float32 value is present in the float32 slice. For example:

quantity := float32(3)
validQuantities := []float32{1,3,5}
Is(v.Float32(quantity).InSlice(validQuantities))

func (*ValidatorFloat32[T]) LessOrEqualTo

func (validator *ValidatorFloat32[T]) LessOrEqualTo(value T, template ...string) *ValidatorFloat32[T]

Validate if the float32 value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := float32(2)
Is(v.Float32(quantity).LessOrEqualTo(float32(2)))

func (*ValidatorFloat32[T]) LessThan

func (validator *ValidatorFloat32[T]) LessThan(value T, template ...string) *ValidatorFloat32[T]

Validate if the float32 value is less than another. This function internally uses the golang `<` operator. For example:

quantity := float32(2)
Is(v.Float32(quantity).LessThan(float32(3)))

func (*ValidatorFloat32[T]) Not

func (validator *ValidatorFloat32[T]) Not() *ValidatorFloat32[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Float32(float32(0)).Not().Zero()).Valid()

func (*ValidatorFloat32[T]) Passing

func (validator *ValidatorFloat32[T]) Passing(function func(v T) bool, template ...string) *ValidatorFloat32[T]

Validate if the float32 value passes a custom function. For example:

quantity := float32(2)
Is(v.Float32(quantity).Passing((v float32) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorFloat32[T]) Zero

func (validator *ValidatorFloat32[T]) Zero(template ...string) *ValidatorFloat32[T]

Validate if the float32 value is zero.

For example:

Is(v.Float32(float32(0)).Zero())

type ValidatorFloat32P

type ValidatorFloat32P[T ~float32] struct {
	// contains filtered or unexported fields
}

The float32 pointer validator type that keeps its validator context.

func Float32P

func Float32P[T ~float32](value *T, nameAndTitle ...string) *ValidatorFloat32P[T]

Receives the float32 pointer to validate.

The value also can be a custom float32 type such as `type Level *float32;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorFloat32P[T]) Between

func (validator *ValidatorFloat32P[T]) Between(min T, max T, template ...string) *ValidatorFloat32P[T]

Validate if the value of the float32 pointer is within a range (inclusive). For example:

n := float32(3)
Is(v.Float32P(&n).Between(float32(2),float32(6)))

func (*ValidatorFloat32P[T]) Context

func (validator *ValidatorFloat32P[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorFloat32P[T]) EqualTo

func (validator *ValidatorFloat32P[T]) EqualTo(value T, template ...string) *ValidatorFloat32P[T]

Validate if the float32 pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := float32(2)
Is(v.Float32P(quantity).Equal(float32(2)))

func (*ValidatorFloat32P[T]) GreaterOrEqualTo

func (validator *ValidatorFloat32P[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorFloat32P[T]

Validate if the float32 pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := float32(3)
Is(v.Float32P(&quantity).GreaterOrEqualTo(float32(3)))

func (*ValidatorFloat32P[T]) GreaterThan

func (validator *ValidatorFloat32P[T]) GreaterThan(value T, template ...string) *ValidatorFloat32P[T]

Validate if the float32 pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := float32(3)
Is(v.Float32P(&quantity).GreaterThan(float32(2)))

func (*ValidatorFloat32P[T]) InSlice

func (validator *ValidatorFloat32P[T]) InSlice(slice []T, template ...string) *ValidatorFloat32P[T]

Validate if the float32 pointer value is present in a numeric slice. For example:

quantity := float32(3)
validQuantities := []float32{1,3,5}
Is(v.Float32P(&quantity).InSlice(validQuantities))

func (*ValidatorFloat32P[T]) LessOrEqualTo

func (validator *ValidatorFloat32P[T]) LessOrEqualTo(value T, template ...string) *ValidatorFloat32P[T]

Validate if the float32 pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := float32(2)
Is(v.Float32P(&quantity).LessOrEqualTo(float32(2)))

func (*ValidatorFloat32P[T]) LessThan

func (validator *ValidatorFloat32P[T]) LessThan(value T, template ...string) *ValidatorFloat32P[T]

Validate if the float32 pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := float32(2)
Is(v.Float32P(&quantity).LessThan(float32(3)))

func (*ValidatorFloat32P[T]) Nil

func (validator *ValidatorFloat32P[T]) Nil(template ...string) *ValidatorFloat32P[T]

Validate if the float32 pointer value is nil.

For example:

var quantity *float32
Is(v.Float32P(quantity).Nil()) // Will be true

func (*ValidatorFloat32P[T]) Not

func (validator *ValidatorFloat32P[T]) Not() *ValidatorFloat32P[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := float32(0)
Is(v.Float32P(&n).Not().Zero()).Valid()

func (*ValidatorFloat32P[T]) Passing

func (validator *ValidatorFloat32P[T]) Passing(function func(v *T) bool, template ...string) *ValidatorFloat32P[T]

Validate if the float32 pointer value passes a custom function. For example:

quantity := float32(2)
Is(v.Float32P(&quantity).Passing((v *float32) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorFloat32P[T]) Zero

func (validator *ValidatorFloat32P[T]) Zero(template ...string) *ValidatorFloat32P[T]

Validate if the float32 pointer value is zero.

For example:

n := float32(0)
Is(v.Float32P(&n).Zero())

func (*ValidatorFloat32P[T]) ZeroOrNil

func (validator *ValidatorFloat32P[T]) ZeroOrNil(template ...string) *ValidatorFloat32P[T]

Validate if the float32 pointer value is zero or nil.

For example:

var _quantity *float32
Is(v.Float32P(_quantity).ZeroOrNil()) // Will be true

type ValidatorFloat64

type ValidatorFloat64[T ~float64] struct {
	// contains filtered or unexported fields
}

The float64 validator type that keeps its validator context.

func Float64

func Float64[T ~float64](value T, nameAndTitle ...string) *ValidatorFloat64[T]

func (*ValidatorFloat64[T]) Between

func (validator *ValidatorFloat64[T]) Between(min T, max T, template ...string) *ValidatorFloat64[T]

Validate if the float64 is within a range (inclusive). For example:

Is(v.Float64(float64(3)).Between(float64(2),float64(6)))

func (*ValidatorFloat64[T]) Context

func (validator *ValidatorFloat64[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorFloat64[T]) EqualTo

func (validator *ValidatorFloat64[T]) EqualTo(value T, template ...string) *ValidatorFloat64[T]

Validate if the float64 value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := float64(2)
Is(v.Float64(quantity).Equal(float64(2)))

func (*ValidatorFloat64[T]) GreaterOrEqualTo

func (validator *ValidatorFloat64[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorFloat64[T]

Validate if the float64 value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := float64(3)
Is(v.Float64(quantity).GreaterOrEqualTo(float64(3)))

func (*ValidatorFloat64[T]) GreaterThan

func (validator *ValidatorFloat64[T]) GreaterThan(value T, template ...string) *ValidatorFloat64[T]

Validate if the float64 value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := float64(3)
Is(v.Float64(quantity).GreaterThan(float64(2)))

func (*ValidatorFloat64[T]) InSlice

func (validator *ValidatorFloat64[T]) InSlice(slice []T, template ...string) *ValidatorFloat64[T]

Validate if the float64 value is present in the float64 slice. For example:

quantity := float64(3)
validQuantities := []float64{1,3,5}
Is(v.Float64(quantity).InSlice(validQuantities))

func (*ValidatorFloat64[T]) LessOrEqualTo

func (validator *ValidatorFloat64[T]) LessOrEqualTo(value T, template ...string) *ValidatorFloat64[T]

Validate if the float64 value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := float64(2)
Is(v.Float64(quantity).LessOrEqualTo(float64(2)))

func (*ValidatorFloat64[T]) LessThan

func (validator *ValidatorFloat64[T]) LessThan(value T, template ...string) *ValidatorFloat64[T]

Validate if the float64 value is less than another. This function internally uses the golang `<` operator. For example:

quantity := float64(2)
Is(v.Float64(quantity).LessThan(float64(3)))

func (*ValidatorFloat64[T]) Not

func (validator *ValidatorFloat64[T]) Not() *ValidatorFloat64[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Float64(float64(0)).Not().Zero()).Valid()

func (*ValidatorFloat64[T]) Passing

func (validator *ValidatorFloat64[T]) Passing(function func(v T) bool, template ...string) *ValidatorFloat64[T]

Validate if the float64 value passes a custom function. For example:

quantity := float64(2)
Is(v.Float64(quantity).Passing((v float64) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorFloat64[T]) Zero

func (validator *ValidatorFloat64[T]) Zero(template ...string) *ValidatorFloat64[T]

Validate if the float64 value is zero.

For example:

Is(v.Float64(float64(0)).Zero())

type ValidatorFloat64P

type ValidatorFloat64P[T ~float64] struct {
	// contains filtered or unexported fields
}

The float64 pointer validator type that keeps its validator context.

func Float64P

func Float64P[T ~float64](value *T, nameAndTitle ...string) *ValidatorFloat64P[T]

Receives the float64 pointer to validate.

The value also can be a custom float64 type such as `type Level *float64;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorFloat64P[T]) Between

func (validator *ValidatorFloat64P[T]) Between(min T, max T, template ...string) *ValidatorFloat64P[T]

Validate if the value of the float64 pointer is within a range (inclusive). For example:

n := float64(3)
Is(v.Float64P(&n).Between(float64(2),float64(6)))

func (*ValidatorFloat64P[T]) Context

func (validator *ValidatorFloat64P[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorFloat64P[T]) EqualTo

func (validator *ValidatorFloat64P[T]) EqualTo(value T, template ...string) *ValidatorFloat64P[T]

Validate if the float64 pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := float64(2)
Is(v.Float64P(quantity).Equal(float64(2)))

func (*ValidatorFloat64P[T]) GreaterOrEqualTo

func (validator *ValidatorFloat64P[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorFloat64P[T]

Validate if the float64 pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := float64(3)
Is(v.Float64P(&quantity).GreaterOrEqualTo(float64(3)))

func (*ValidatorFloat64P[T]) GreaterThan

func (validator *ValidatorFloat64P[T]) GreaterThan(value T, template ...string) *ValidatorFloat64P[T]

Validate if the float64 pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := float64(3)
Is(v.Float64P(&quantity).GreaterThan(float64(2)))

func (*ValidatorFloat64P[T]) InSlice

func (validator *ValidatorFloat64P[T]) InSlice(slice []T, template ...string) *ValidatorFloat64P[T]

Validate if the float64 pointer value is present in a numeric slice. For example:

quantity := float64(3)
validQuantities := []float64{1,3,5}
Is(v.Float64P(&quantity).InSlice(validQuantities))

func (*ValidatorFloat64P[T]) LessOrEqualTo

func (validator *ValidatorFloat64P[T]) LessOrEqualTo(value T, template ...string) *ValidatorFloat64P[T]

Validate if the float64 pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := float64(2)
Is(v.Float64P(&quantity).LessOrEqualTo(float64(2)))

func (*ValidatorFloat64P[T]) LessThan

func (validator *ValidatorFloat64P[T]) LessThan(value T, template ...string) *ValidatorFloat64P[T]

Validate if the float64 pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := float64(2)
Is(v.Float64P(&quantity).LessThan(float64(3)))

func (*ValidatorFloat64P[T]) Nil

func (validator *ValidatorFloat64P[T]) Nil(template ...string) *ValidatorFloat64P[T]

Validate if the float64 pointer value is nil.

For example:

var quantity *float64
Is(v.Float64P(quantity).Nil()) // Will be true

func (*ValidatorFloat64P[T]) Not

func (validator *ValidatorFloat64P[T]) Not() *ValidatorFloat64P[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := float64(0)
Is(v.Float64P(&n).Not().Zero()).Valid()

func (*ValidatorFloat64P[T]) Passing

func (validator *ValidatorFloat64P[T]) Passing(function func(v *T) bool, template ...string) *ValidatorFloat64P[T]

Validate if the float64 pointer value passes a custom function. For example:

quantity := float64(2)
Is(v.Float64P(&quantity).Passing((v *float64) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorFloat64P[T]) Zero

func (validator *ValidatorFloat64P[T]) Zero(template ...string) *ValidatorFloat64P[T]

Validate if the float64 pointer value is zero.

For example:

n := float64(0)
Is(v.Float64P(&n).Zero())

func (*ValidatorFloat64P[T]) ZeroOrNil

func (validator *ValidatorFloat64P[T]) ZeroOrNil(template ...string) *ValidatorFloat64P[T]

Validate if the float64 pointer value is zero or nil.

For example:

var _quantity *float64
Is(v.Float64P(_quantity).ZeroOrNil()) // Will be true

type ValidatorInt

type ValidatorInt[T ~int] struct {
	// contains filtered or unexported fields
}

The int validator type that keeps its validator context.

func Int

func Int[T ~int](value T, nameAndTitle ...string) *ValidatorInt[T]

func (*ValidatorInt[T]) Between

func (validator *ValidatorInt[T]) Between(min T, max T, template ...string) *ValidatorInt[T]

Validate if the int is within a range (inclusive). For example:

Is(v.Int(int(3)).Between(int(2),int(6)))

func (*ValidatorInt[T]) Context

func (validator *ValidatorInt[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorInt[T]) EqualTo

func (validator *ValidatorInt[T]) EqualTo(value T, template ...string) *ValidatorInt[T]

Validate if the int value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := int(2)
Is(v.Int(quantity).Equal(int(2)))

func (*ValidatorInt[T]) GreaterOrEqualTo

func (validator *ValidatorInt[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorInt[T]

Validate if the int value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := int(3)
Is(v.Int(quantity).GreaterOrEqualTo(int(3)))

func (*ValidatorInt[T]) GreaterThan

func (validator *ValidatorInt[T]) GreaterThan(value T, template ...string) *ValidatorInt[T]

Validate if the int value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := int(3)
Is(v.Int(quantity).GreaterThan(int(2)))

func (*ValidatorInt[T]) InSlice

func (validator *ValidatorInt[T]) InSlice(slice []T, template ...string) *ValidatorInt[T]

Validate if the int value is present in the int slice. For example:

quantity := int(3)
validQuantities := []int{1,3,5}
Is(v.Int(quantity).InSlice(validQuantities))

func (*ValidatorInt[T]) LessOrEqualTo

func (validator *ValidatorInt[T]) LessOrEqualTo(value T, template ...string) *ValidatorInt[T]

Validate if the int value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := int(2)
Is(v.Int(quantity).LessOrEqualTo(int(2)))

func (*ValidatorInt[T]) LessThan

func (validator *ValidatorInt[T]) LessThan(value T, template ...string) *ValidatorInt[T]

Validate if the int value is less than another. This function internally uses the golang `<` operator. For example:

quantity := int(2)
Is(v.Int(quantity).LessThan(int(3)))

func (*ValidatorInt[T]) Not

func (validator *ValidatorInt[T]) Not() *ValidatorInt[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Int(int(0)).Not().Zero()).Valid()

func (*ValidatorInt[T]) Passing

func (validator *ValidatorInt[T]) Passing(function func(v T) bool, template ...string) *ValidatorInt[T]

Validate if the int value passes a custom function. For example:

quantity := int(2)
Is(v.Int(quantity).Passing((v int) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorInt[T]) Zero

func (validator *ValidatorInt[T]) Zero(template ...string) *ValidatorInt[T]

Validate if the int value is zero.

For example:

Is(v.Int(int(0)).Zero())

type ValidatorInt16

type ValidatorInt16[T ~int16] struct {
	// contains filtered or unexported fields
}

The int16 validator type that keeps its validator context.

func Int16

func Int16[T ~int16](value T, nameAndTitle ...string) *ValidatorInt16[T]

func (*ValidatorInt16[T]) Between

func (validator *ValidatorInt16[T]) Between(min T, max T, template ...string) *ValidatorInt16[T]

Validate if the int16 is within a range (inclusive). For example:

Is(v.Int16(int16(3)).Between(int16(2),int16(6)))

func (*ValidatorInt16[T]) Context

func (validator *ValidatorInt16[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorInt16[T]) EqualTo

func (validator *ValidatorInt16[T]) EqualTo(value T, template ...string) *ValidatorInt16[T]

Validate if the int16 value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := int16(2)
Is(v.Int16(quantity).Equal(int16(2)))

func (*ValidatorInt16[T]) GreaterOrEqualTo

func (validator *ValidatorInt16[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorInt16[T]

Validate if the int16 value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := int16(3)
Is(v.Int16(quantity).GreaterOrEqualTo(int16(3)))

func (*ValidatorInt16[T]) GreaterThan

func (validator *ValidatorInt16[T]) GreaterThan(value T, template ...string) *ValidatorInt16[T]

Validate if the int16 value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := int16(3)
Is(v.Int16(quantity).GreaterThan(int16(2)))

func (*ValidatorInt16[T]) InSlice

func (validator *ValidatorInt16[T]) InSlice(slice []T, template ...string) *ValidatorInt16[T]

Validate if the int16 value is present in the int16 slice. For example:

quantity := int16(3)
validQuantities := []int16{1,3,5}
Is(v.Int16(quantity).InSlice(validQuantities))

func (*ValidatorInt16[T]) LessOrEqualTo

func (validator *ValidatorInt16[T]) LessOrEqualTo(value T, template ...string) *ValidatorInt16[T]

Validate if the int16 value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := int16(2)
Is(v.Int16(quantity).LessOrEqualTo(int16(2)))

func (*ValidatorInt16[T]) LessThan

func (validator *ValidatorInt16[T]) LessThan(value T, template ...string) *ValidatorInt16[T]

Validate if the int16 value is less than another. This function internally uses the golang `<` operator. For example:

quantity := int16(2)
Is(v.Int16(quantity).LessThan(int16(3)))

func (*ValidatorInt16[T]) Not

func (validator *ValidatorInt16[T]) Not() *ValidatorInt16[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Int16(int16(0)).Not().Zero()).Valid()

func (*ValidatorInt16[T]) Passing

func (validator *ValidatorInt16[T]) Passing(function func(v T) bool, template ...string) *ValidatorInt16[T]

Validate if the int16 value passes a custom function. For example:

quantity := int16(2)
Is(v.Int16(quantity).Passing((v int16) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorInt16[T]) Zero

func (validator *ValidatorInt16[T]) Zero(template ...string) *ValidatorInt16[T]

Validate if the int16 value is zero.

For example:

Is(v.Int16(int16(0)).Zero())

type ValidatorInt16P

type ValidatorInt16P[T ~int16] struct {
	// contains filtered or unexported fields
}

The int16 pointer validator type that keeps its validator context.

func Int16P

func Int16P[T ~int16](value *T, nameAndTitle ...string) *ValidatorInt16P[T]

Receives the int16 pointer to validate.

The value also can be a custom int16 type such as `type Level *int16;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorInt16P[T]) Between

func (validator *ValidatorInt16P[T]) Between(min T, max T, template ...string) *ValidatorInt16P[T]

Validate if the value of the int16 pointer is within a range (inclusive). For example:

n := int16(3)
Is(v.Int16P(&n).Between(int16(2),int16(6)))

func (*ValidatorInt16P[T]) Context

func (validator *ValidatorInt16P[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorInt16P[T]) EqualTo

func (validator *ValidatorInt16P[T]) EqualTo(value T, template ...string) *ValidatorInt16P[T]

Validate if the int16 pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := int16(2)
Is(v.Int16P(quantity).Equal(int16(2)))

func (*ValidatorInt16P[T]) GreaterOrEqualTo

func (validator *ValidatorInt16P[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorInt16P[T]

Validate if the int16 pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := int16(3)
Is(v.Int16P(&quantity).GreaterOrEqualTo(int16(3)))

func (*ValidatorInt16P[T]) GreaterThan

func (validator *ValidatorInt16P[T]) GreaterThan(value T, template ...string) *ValidatorInt16P[T]

Validate if the int16 pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := int16(3)
Is(v.Int16P(&quantity).GreaterThan(int16(2)))

func (*ValidatorInt16P[T]) InSlice

func (validator *ValidatorInt16P[T]) InSlice(slice []T, template ...string) *ValidatorInt16P[T]

Validate if the int16 pointer value is present in a numeric slice. For example:

quantity := int16(3)
validQuantities := []int16{1,3,5}
Is(v.Int16P(&quantity).InSlice(validQuantities))

func (*ValidatorInt16P[T]) LessOrEqualTo

func (validator *ValidatorInt16P[T]) LessOrEqualTo(value T, template ...string) *ValidatorInt16P[T]

Validate if the int16 pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := int16(2)
Is(v.Int16P(&quantity).LessOrEqualTo(int16(2)))

func (*ValidatorInt16P[T]) LessThan

func (validator *ValidatorInt16P[T]) LessThan(value T, template ...string) *ValidatorInt16P[T]

Validate if the int16 pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := int16(2)
Is(v.Int16P(&quantity).LessThan(int16(3)))

func (*ValidatorInt16P[T]) Nil

func (validator *ValidatorInt16P[T]) Nil(template ...string) *ValidatorInt16P[T]

Validate if the int16 pointer value is nil.

For example:

var quantity *int16
Is(v.Int16P(quantity).Nil()) // Will be true

func (*ValidatorInt16P[T]) Not

func (validator *ValidatorInt16P[T]) Not() *ValidatorInt16P[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := int16(0)
Is(v.Int16P(&n).Not().Zero()).Valid()

func (*ValidatorInt16P[T]) Passing

func (validator *ValidatorInt16P[T]) Passing(function func(v *T) bool, template ...string) *ValidatorInt16P[T]

Validate if the int16 pointer value passes a custom function. For example:

quantity := int16(2)
Is(v.Int16P(&quantity).Passing((v *int16) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorInt16P[T]) Zero

func (validator *ValidatorInt16P[T]) Zero(template ...string) *ValidatorInt16P[T]

Validate if the int16 pointer value is zero.

For example:

n := int16(0)
Is(v.Int16P(&n).Zero())

func (*ValidatorInt16P[T]) ZeroOrNil

func (validator *ValidatorInt16P[T]) ZeroOrNil(template ...string) *ValidatorInt16P[T]

Validate if the int16 pointer value is zero or nil.

For example:

var _quantity *int16
Is(v.Int16P(_quantity).ZeroOrNil()) // Will be true

type ValidatorInt32

type ValidatorInt32[T ~int32] struct {
	// contains filtered or unexported fields
}

The int32 validator type that keeps its validator context.

func Int32

func Int32[T ~int32](value T, nameAndTitle ...string) *ValidatorInt32[T]

func (*ValidatorInt32[T]) Between

func (validator *ValidatorInt32[T]) Between(min T, max T, template ...string) *ValidatorInt32[T]

Validate if the int32 is within a range (inclusive). For example:

Is(v.Int32(int32(3)).Between(int32(2),int32(6)))

func (*ValidatorInt32[T]) Context

func (validator *ValidatorInt32[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorInt32[T]) EqualTo

func (validator *ValidatorInt32[T]) EqualTo(value T, template ...string) *ValidatorInt32[T]

Validate if the int32 value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := int32(2)
Is(v.Int32(quantity).Equal(int32(2)))

func (*ValidatorInt32[T]) GreaterOrEqualTo

func (validator *ValidatorInt32[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorInt32[T]

Validate if the int32 value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := int32(3)
Is(v.Int32(quantity).GreaterOrEqualTo(int32(3)))

func (*ValidatorInt32[T]) GreaterThan

func (validator *ValidatorInt32[T]) GreaterThan(value T, template ...string) *ValidatorInt32[T]

Validate if the int32 value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := int32(3)
Is(v.Int32(quantity).GreaterThan(int32(2)))

func (*ValidatorInt32[T]) InSlice

func (validator *ValidatorInt32[T]) InSlice(slice []T, template ...string) *ValidatorInt32[T]

Validate if the int32 value is present in the int32 slice. For example:

quantity := int32(3)
validQuantities := []int32{1,3,5}
Is(v.Int32(quantity).InSlice(validQuantities))

func (*ValidatorInt32[T]) LessOrEqualTo

func (validator *ValidatorInt32[T]) LessOrEqualTo(value T, template ...string) *ValidatorInt32[T]

Validate if the int32 value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := int32(2)
Is(v.Int32(quantity).LessOrEqualTo(int32(2)))

func (*ValidatorInt32[T]) LessThan

func (validator *ValidatorInt32[T]) LessThan(value T, template ...string) *ValidatorInt32[T]

Validate if the int32 value is less than another. This function internally uses the golang `<` operator. For example:

quantity := int32(2)
Is(v.Int32(quantity).LessThan(int32(3)))

func (*ValidatorInt32[T]) Not

func (validator *ValidatorInt32[T]) Not() *ValidatorInt32[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Int32(int32(0)).Not().Zero()).Valid()

func (*ValidatorInt32[T]) Passing

func (validator *ValidatorInt32[T]) Passing(function func(v T) bool, template ...string) *ValidatorInt32[T]

Validate if the int32 value passes a custom function. For example:

quantity := int32(2)
Is(v.Int32(quantity).Passing((v int32) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorInt32[T]) Zero

func (validator *ValidatorInt32[T]) Zero(template ...string) *ValidatorInt32[T]

Validate if the int32 value is zero.

For example:

Is(v.Int32(int32(0)).Zero())

type ValidatorInt32P

type ValidatorInt32P[T ~int32] struct {
	// contains filtered or unexported fields
}

The int32 pointer validator type that keeps its validator context.

func Int32P

func Int32P[T ~int32](value *T, nameAndTitle ...string) *ValidatorInt32P[T]

Receives the int32 pointer to validate.

The value also can be a custom int32 type such as `type Level *int32;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorInt32P[T]) Between

func (validator *ValidatorInt32P[T]) Between(min T, max T, template ...string) *ValidatorInt32P[T]

Validate if the value of the int32 pointer is within a range (inclusive). For example:

n := int32(3)
Is(v.Int32P(&n).Between(int32(2),int32(6)))

func (*ValidatorInt32P[T]) Context

func (validator *ValidatorInt32P[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorInt32P[T]) EqualTo

func (validator *ValidatorInt32P[T]) EqualTo(value T, template ...string) *ValidatorInt32P[T]

Validate if the int32 pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := int32(2)
Is(v.Int32P(quantity).Equal(int32(2)))

func (*ValidatorInt32P[T]) GreaterOrEqualTo

func (validator *ValidatorInt32P[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorInt32P[T]

Validate if the int32 pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := int32(3)
Is(v.Int32P(&quantity).GreaterOrEqualTo(int32(3)))

func (*ValidatorInt32P[T]) GreaterThan

func (validator *ValidatorInt32P[T]) GreaterThan(value T, template ...string) *ValidatorInt32P[T]

Validate if the int32 pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := int32(3)
Is(v.Int32P(&quantity).GreaterThan(int32(2)))

func (*ValidatorInt32P[T]) InSlice

func (validator *ValidatorInt32P[T]) InSlice(slice []T, template ...string) *ValidatorInt32P[T]

Validate if the int32 pointer value is present in a numeric slice. For example:

quantity := int32(3)
validQuantities := []int32{1,3,5}
Is(v.Int32P(&quantity).InSlice(validQuantities))

func (*ValidatorInt32P[T]) LessOrEqualTo

func (validator *ValidatorInt32P[T]) LessOrEqualTo(value T, template ...string) *ValidatorInt32P[T]

Validate if the int32 pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := int32(2)
Is(v.Int32P(&quantity).LessOrEqualTo(int32(2)))

func (*ValidatorInt32P[T]) LessThan

func (validator *ValidatorInt32P[T]) LessThan(value T, template ...string) *ValidatorInt32P[T]

Validate if the int32 pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := int32(2)
Is(v.Int32P(&quantity).LessThan(int32(3)))

func (*ValidatorInt32P[T]) Nil

func (validator *ValidatorInt32P[T]) Nil(template ...string) *ValidatorInt32P[T]

Validate if the int32 pointer value is nil.

For example:

var quantity *int32
Is(v.Int32P(quantity).Nil()) // Will be true

func (*ValidatorInt32P[T]) Not

func (validator *ValidatorInt32P[T]) Not() *ValidatorInt32P[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := int32(0)
Is(v.Int32P(&n).Not().Zero()).Valid()

func (*ValidatorInt32P[T]) Passing

func (validator *ValidatorInt32P[T]) Passing(function func(v *T) bool, template ...string) *ValidatorInt32P[T]

Validate if the int32 pointer value passes a custom function. For example:

quantity := int32(2)
Is(v.Int32P(&quantity).Passing((v *int32) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorInt32P[T]) Zero

func (validator *ValidatorInt32P[T]) Zero(template ...string) *ValidatorInt32P[T]

Validate if the int32 pointer value is zero.

For example:

n := int32(0)
Is(v.Int32P(&n).Zero())

func (*ValidatorInt32P[T]) ZeroOrNil

func (validator *ValidatorInt32P[T]) ZeroOrNil(template ...string) *ValidatorInt32P[T]

Validate if the int32 pointer value is zero or nil.

For example:

var _quantity *int32
Is(v.Int32P(_quantity).ZeroOrNil()) // Will be true

type ValidatorInt64

type ValidatorInt64[T ~int64] struct {
	// contains filtered or unexported fields
}

The int64 validator type that keeps its validator context.

func Int64

func Int64[T ~int64](value T, nameAndTitle ...string) *ValidatorInt64[T]

func (*ValidatorInt64[T]) Between

func (validator *ValidatorInt64[T]) Between(min T, max T, template ...string) *ValidatorInt64[T]

Validate if the int64 is within a range (inclusive). For example:

Is(v.Int64(int64(3)).Between(int64(2),int64(6)))

func (*ValidatorInt64[T]) Context

func (validator *ValidatorInt64[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorInt64[T]) EqualTo

func (validator *ValidatorInt64[T]) EqualTo(value T, template ...string) *ValidatorInt64[T]

Validate if the int64 value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := int64(2)
Is(v.Int64(quantity).Equal(int64(2)))

func (*ValidatorInt64[T]) GreaterOrEqualTo

func (validator *ValidatorInt64[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorInt64[T]

Validate if the int64 value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := int64(3)
Is(v.Int64(quantity).GreaterOrEqualTo(int64(3)))

func (*ValidatorInt64[T]) GreaterThan

func (validator *ValidatorInt64[T]) GreaterThan(value T, template ...string) *ValidatorInt64[T]

Validate if the int64 value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := int64(3)
Is(v.Int64(quantity).GreaterThan(int64(2)))

func (*ValidatorInt64[T]) InSlice

func (validator *ValidatorInt64[T]) InSlice(slice []T, template ...string) *ValidatorInt64[T]

Validate if the int64 value is present in the int64 slice. For example:

quantity := int64(3)
validQuantities := []int64{1,3,5}
Is(v.Int64(quantity).InSlice(validQuantities))

func (*ValidatorInt64[T]) LessOrEqualTo

func (validator *ValidatorInt64[T]) LessOrEqualTo(value T, template ...string) *ValidatorInt64[T]

Validate if the int64 value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := int64(2)
Is(v.Int64(quantity).LessOrEqualTo(int64(2)))

func (*ValidatorInt64[T]) LessThan

func (validator *ValidatorInt64[T]) LessThan(value T, template ...string) *ValidatorInt64[T]

Validate if the int64 value is less than another. This function internally uses the golang `<` operator. For example:

quantity := int64(2)
Is(v.Int64(quantity).LessThan(int64(3)))

func (*ValidatorInt64[T]) Not

func (validator *ValidatorInt64[T]) Not() *ValidatorInt64[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Int64(int64(0)).Not().Zero()).Valid()

func (*ValidatorInt64[T]) Passing

func (validator *ValidatorInt64[T]) Passing(function func(v T) bool, template ...string) *ValidatorInt64[T]

Validate if the int64 value passes a custom function. For example:

quantity := int64(2)
Is(v.Int64(quantity).Passing((v int64) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorInt64[T]) Zero

func (validator *ValidatorInt64[T]) Zero(template ...string) *ValidatorInt64[T]

Validate if the int64 value is zero.

For example:

Is(v.Int64(int64(0)).Zero())

type ValidatorInt64P

type ValidatorInt64P[T ~int64] struct {
	// contains filtered or unexported fields
}

The int64 pointer validator type that keeps its validator context.

func Int64P

func Int64P[T ~int64](value *T, nameAndTitle ...string) *ValidatorInt64P[T]

Receives the int64 pointer to validate.

The value also can be a custom int64 type such as `type Level *int64;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorInt64P[T]) Between

func (validator *ValidatorInt64P[T]) Between(min T, max T, template ...string) *ValidatorInt64P[T]

Validate if the value of the int64 pointer is within a range (inclusive). For example:

n := int64(3)
Is(v.Int64P(&n).Between(int64(2),int64(6)))

func (*ValidatorInt64P[T]) Context

func (validator *ValidatorInt64P[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorInt64P[T]) EqualTo

func (validator *ValidatorInt64P[T]) EqualTo(value T, template ...string) *ValidatorInt64P[T]

Validate if the int64 pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := int64(2)
Is(v.Int64P(quantity).Equal(int64(2)))

func (*ValidatorInt64P[T]) GreaterOrEqualTo

func (validator *ValidatorInt64P[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorInt64P[T]

Validate if the int64 pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := int64(3)
Is(v.Int64P(&quantity).GreaterOrEqualTo(int64(3)))

func (*ValidatorInt64P[T]) GreaterThan

func (validator *ValidatorInt64P[T]) GreaterThan(value T, template ...string) *ValidatorInt64P[T]

Validate if the int64 pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := int64(3)
Is(v.Int64P(&quantity).GreaterThan(int64(2)))

func (*ValidatorInt64P[T]) InSlice

func (validator *ValidatorInt64P[T]) InSlice(slice []T, template ...string) *ValidatorInt64P[T]

Validate if the int64 pointer value is present in a numeric slice. For example:

quantity := int64(3)
validQuantities := []int64{1,3,5}
Is(v.Int64P(&quantity).InSlice(validQuantities))

func (*ValidatorInt64P[T]) LessOrEqualTo

func (validator *ValidatorInt64P[T]) LessOrEqualTo(value T, template ...string) *ValidatorInt64P[T]

Validate if the int64 pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := int64(2)
Is(v.Int64P(&quantity).LessOrEqualTo(int64(2)))

func (*ValidatorInt64P[T]) LessThan

func (validator *ValidatorInt64P[T]) LessThan(value T, template ...string) *ValidatorInt64P[T]

Validate if the int64 pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := int64(2)
Is(v.Int64P(&quantity).LessThan(int64(3)))

func (*ValidatorInt64P[T]) Nil

func (validator *ValidatorInt64P[T]) Nil(template ...string) *ValidatorInt64P[T]

Validate if the int64 pointer value is nil.

For example:

var quantity *int64
Is(v.Int64P(quantity).Nil()) // Will be true

func (*ValidatorInt64P[T]) Not

func (validator *ValidatorInt64P[T]) Not() *ValidatorInt64P[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := int64(0)
Is(v.Int64P(&n).Not().Zero()).Valid()

func (*ValidatorInt64P[T]) Passing

func (validator *ValidatorInt64P[T]) Passing(function func(v *T) bool, template ...string) *ValidatorInt64P[T]

Validate if the int64 pointer value passes a custom function. For example:

quantity := int64(2)
Is(v.Int64P(&quantity).Passing((v *int64) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorInt64P[T]) Zero

func (validator *ValidatorInt64P[T]) Zero(template ...string) *ValidatorInt64P[T]

Validate if the int64 pointer value is zero.

For example:

n := int64(0)
Is(v.Int64P(&n).Zero())

func (*ValidatorInt64P[T]) ZeroOrNil

func (validator *ValidatorInt64P[T]) ZeroOrNil(template ...string) *ValidatorInt64P[T]

Validate if the int64 pointer value is zero or nil.

For example:

var _quantity *int64
Is(v.Int64P(_quantity).ZeroOrNil()) // Will be true

type ValidatorInt8

type ValidatorInt8[T ~int8] struct {
	// contains filtered or unexported fields
}

The int8 validator type that keeps its validator context.

func Int8

func Int8[T ~int8](value T, nameAndTitle ...string) *ValidatorInt8[T]

func (*ValidatorInt8[T]) Between

func (validator *ValidatorInt8[T]) Between(min T, max T, template ...string) *ValidatorInt8[T]

Validate if the int8 is within a range (inclusive). For example:

Is(v.Int8(int8(3)).Between(int8(2),int8(6)))

func (*ValidatorInt8[T]) Context

func (validator *ValidatorInt8[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorInt8[T]) EqualTo

func (validator *ValidatorInt8[T]) EqualTo(value T, template ...string) *ValidatorInt8[T]

Validate if the int8 value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := int8(2)
Is(v.Int8(quantity).Equal(int8(2)))

func (*ValidatorInt8[T]) GreaterOrEqualTo

func (validator *ValidatorInt8[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorInt8[T]

Validate if the int8 value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := int8(3)
Is(v.Int8(quantity).GreaterOrEqualTo(int8(3)))

func (*ValidatorInt8[T]) GreaterThan

func (validator *ValidatorInt8[T]) GreaterThan(value T, template ...string) *ValidatorInt8[T]

Validate if the int8 value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := int8(3)
Is(v.Int8(quantity).GreaterThan(int8(2)))

func (*ValidatorInt8[T]) InSlice

func (validator *ValidatorInt8[T]) InSlice(slice []T, template ...string) *ValidatorInt8[T]

Validate if the int8 value is present in the int8 slice. For example:

quantity := int8(3)
validQuantities := []int8{1,3,5}
Is(v.Int8(quantity).InSlice(validQuantities))

func (*ValidatorInt8[T]) LessOrEqualTo

func (validator *ValidatorInt8[T]) LessOrEqualTo(value T, template ...string) *ValidatorInt8[T]

Validate if the int8 value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := int8(2)
Is(v.Int8(quantity).LessOrEqualTo(int8(2)))

func (*ValidatorInt8[T]) LessThan

func (validator *ValidatorInt8[T]) LessThan(value T, template ...string) *ValidatorInt8[T]

Validate if the int8 value is less than another. This function internally uses the golang `<` operator. For example:

quantity := int8(2)
Is(v.Int8(quantity).LessThan(int8(3)))

func (*ValidatorInt8[T]) Not

func (validator *ValidatorInt8[T]) Not() *ValidatorInt8[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Int8(int8(0)).Not().Zero()).Valid()

func (*ValidatorInt8[T]) Passing

func (validator *ValidatorInt8[T]) Passing(function func(v T) bool, template ...string) *ValidatorInt8[T]

Validate if the int8 value passes a custom function. For example:

quantity := int8(2)
Is(v.Int8(quantity).Passing((v int8) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorInt8[T]) Zero

func (validator *ValidatorInt8[T]) Zero(template ...string) *ValidatorInt8[T]

Validate if the int8 value is zero.

For example:

Is(v.Int8(int8(0)).Zero())

type ValidatorInt8P

type ValidatorInt8P[T ~int8] struct {
	// contains filtered or unexported fields
}

The int8 pointer validator type that keeps its validator context.

func Int8P

func Int8P[T ~int8](value *T, nameAndTitle ...string) *ValidatorInt8P[T]

Receives the int8 pointer to validate.

The value also can be a custom int8 type such as `type Level *int8;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorInt8P[T]) Between

func (validator *ValidatorInt8P[T]) Between(min T, max T, template ...string) *ValidatorInt8P[T]

Validate if the value of the int8 pointer is within a range (inclusive). For example:

n := int8(3)
Is(v.Int8P(&n).Between(int8(2),int8(6)))

func (*ValidatorInt8P[T]) Context

func (validator *ValidatorInt8P[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorInt8P[T]) EqualTo

func (validator *ValidatorInt8P[T]) EqualTo(value T, template ...string) *ValidatorInt8P[T]

Validate if the int8 pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := int8(2)
Is(v.Int8P(quantity).Equal(int8(2)))

func (*ValidatorInt8P[T]) GreaterOrEqualTo

func (validator *ValidatorInt8P[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorInt8P[T]

Validate if the int8 pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := int8(3)
Is(v.Int8P(&quantity).GreaterOrEqualTo(int8(3)))

func (*ValidatorInt8P[T]) GreaterThan

func (validator *ValidatorInt8P[T]) GreaterThan(value T, template ...string) *ValidatorInt8P[T]

Validate if the int8 pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := int8(3)
Is(v.Int8P(&quantity).GreaterThan(int8(2)))

func (*ValidatorInt8P[T]) InSlice

func (validator *ValidatorInt8P[T]) InSlice(slice []T, template ...string) *ValidatorInt8P[T]

Validate if the int8 pointer value is present in a numeric slice. For example:

quantity := int8(3)
validQuantities := []int8{1,3,5}
Is(v.Int8P(&quantity).InSlice(validQuantities))

func (*ValidatorInt8P[T]) LessOrEqualTo

func (validator *ValidatorInt8P[T]) LessOrEqualTo(value T, template ...string) *ValidatorInt8P[T]

Validate if the int8 pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := int8(2)
Is(v.Int8P(&quantity).LessOrEqualTo(int8(2)))

func (*ValidatorInt8P[T]) LessThan

func (validator *ValidatorInt8P[T]) LessThan(value T, template ...string) *ValidatorInt8P[T]

Validate if the int8 pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := int8(2)
Is(v.Int8P(&quantity).LessThan(int8(3)))

func (*ValidatorInt8P[T]) Nil

func (validator *ValidatorInt8P[T]) Nil(template ...string) *ValidatorInt8P[T]

Validate if the int8 pointer value is nil.

For example:

var quantity *int8
Is(v.Int8P(quantity).Nil()) // Will be true

func (*ValidatorInt8P[T]) Not

func (validator *ValidatorInt8P[T]) Not() *ValidatorInt8P[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := int8(0)
Is(v.Int8P(&n).Not().Zero()).Valid()

func (*ValidatorInt8P[T]) Passing

func (validator *ValidatorInt8P[T]) Passing(function func(v *T) bool, template ...string) *ValidatorInt8P[T]

Validate if the int8 pointer value passes a custom function. For example:

quantity := int8(2)
Is(v.Int8P(&quantity).Passing((v *int8) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorInt8P[T]) Zero

func (validator *ValidatorInt8P[T]) Zero(template ...string) *ValidatorInt8P[T]

Validate if the int8 pointer value is zero.

For example:

n := int8(0)
Is(v.Int8P(&n).Zero())

func (*ValidatorInt8P[T]) ZeroOrNil

func (validator *ValidatorInt8P[T]) ZeroOrNil(template ...string) *ValidatorInt8P[T]

Validate if the int8 pointer value is zero or nil.

For example:

var _quantity *int8
Is(v.Int8P(_quantity).ZeroOrNil()) // Will be true

type ValidatorIntP

type ValidatorIntP[T ~int] struct {
	// contains filtered or unexported fields
}

The int pointer validator type that keeps its validator context.

func IntP

func IntP[T ~int](value *T, nameAndTitle ...string) *ValidatorIntP[T]

Receives the int pointer to validate.

The value also can be a custom int type such as `type Level *int;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorIntP[T]) Between

func (validator *ValidatorIntP[T]) Between(min T, max T, template ...string) *ValidatorIntP[T]

Validate if the value of the int pointer is within a range (inclusive). For example:

n := int(3)
Is(v.IntP(&n).Between(int(2),int(6)))

func (*ValidatorIntP[T]) Context

func (validator *ValidatorIntP[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorIntP[T]) EqualTo

func (validator *ValidatorIntP[T]) EqualTo(value T, template ...string) *ValidatorIntP[T]

Validate if the int pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := int(2)
Is(v.IntP(quantity).Equal(int(2)))

func (*ValidatorIntP[T]) GreaterOrEqualTo

func (validator *ValidatorIntP[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorIntP[T]

Validate if the int pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := int(3)
Is(v.IntP(&quantity).GreaterOrEqualTo(int(3)))

func (*ValidatorIntP[T]) GreaterThan

func (validator *ValidatorIntP[T]) GreaterThan(value T, template ...string) *ValidatorIntP[T]

Validate if the int pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := int(3)
Is(v.IntP(&quantity).GreaterThan(int(2)))

func (*ValidatorIntP[T]) InSlice

func (validator *ValidatorIntP[T]) InSlice(slice []T, template ...string) *ValidatorIntP[T]

Validate if the int pointer value is present in a numeric slice. For example:

quantity := int(3)
validQuantities := []int{1,3,5}
Is(v.IntP(&quantity).InSlice(validQuantities))

func (*ValidatorIntP[T]) LessOrEqualTo

func (validator *ValidatorIntP[T]) LessOrEqualTo(value T, template ...string) *ValidatorIntP[T]

Validate if the int pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := int(2)
Is(v.IntP(&quantity).LessOrEqualTo(int(2)))

func (*ValidatorIntP[T]) LessThan

func (validator *ValidatorIntP[T]) LessThan(value T, template ...string) *ValidatorIntP[T]

Validate if the int pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := int(2)
Is(v.IntP(&quantity).LessThan(int(3)))

func (*ValidatorIntP[T]) Nil

func (validator *ValidatorIntP[T]) Nil(template ...string) *ValidatorIntP[T]

Validate if the int pointer value is nil.

For example:

var quantity *int
Is(v.IntP(quantity).Nil()) // Will be true

func (*ValidatorIntP[T]) Not

func (validator *ValidatorIntP[T]) Not() *ValidatorIntP[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := int(0)
Is(v.IntP(&n).Not().Zero()).Valid()

func (*ValidatorIntP[T]) Passing

func (validator *ValidatorIntP[T]) Passing(function func(v *T) bool, template ...string) *ValidatorIntP[T]

Validate if the int pointer value passes a custom function. For example:

quantity := int(2)
Is(v.IntP(&quantity).Passing((v *int) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorIntP[T]) Zero

func (validator *ValidatorIntP[T]) Zero(template ...string) *ValidatorIntP[T]

Validate if the int pointer value is zero.

For example:

n := int(0)
Is(v.IntP(&n).Zero())

func (*ValidatorIntP[T]) ZeroOrNil

func (validator *ValidatorIntP[T]) ZeroOrNil(template ...string) *ValidatorIntP[T]

Validate if the int pointer value is zero or nil.

For example:

var _quantity *int
Is(v.IntP(_quantity).ZeroOrNil()) // Will be true

type ValidatorNumber

type ValidatorNumber[T TypeNumber] struct {
	// contains filtered or unexported fields
}

The ValidatorNumber provides functions for setting validation rules for a TypeNumber value type, or a custom type based on a TypeNumber.

TypeNumber is a generic interface defined by Valgo that generalizes any standard Golang type.

func Number

func Number[T TypeNumber](value T, nameAndTitle ...string) *ValidatorNumber[T]

func (*ValidatorNumber[T]) Between

func (validator *ValidatorNumber[T]) Between(min T, max T, template ...string) *ValidatorNumber[T]

Validate if a number is within a range (inclusive). For example:

Is(v.Number(3).Between(2,6))

func (*ValidatorNumber[T]) Context

func (validator *ValidatorNumber[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorNumber[T]) EqualTo

func (validator *ValidatorNumber[T]) EqualTo(value T, template ...string) *ValidatorNumber[T]

Validate if a numeric value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := 2
Is(v.Number(quantity).Equal(2))

func (*ValidatorNumber[T]) GreaterOrEqualTo

func (validator *ValidatorNumber[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorNumber[T]

Validate if a numeric value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := 3
Is(v.Number(quantity).GreaterOrEqualTo(3))

func (*ValidatorNumber[T]) GreaterThan

func (validator *ValidatorNumber[T]) GreaterThan(value T, template ...string) *ValidatorNumber[T]

Validate if a numeric value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := 3
Is(v.Number(quantity).GreaterThan(2))

func (*ValidatorNumber[T]) InSlice

func (validator *ValidatorNumber[T]) InSlice(slice []T, template ...string) *ValidatorNumber[T]

Validate if a number is present in a numeric slice. For example:

quantity := 3
validQuantities := []int{1,3,5}
Is(v.Number(quantity).InSlice(validQuantities))

func (*ValidatorNumber[T]) LessOrEqualTo

func (validator *ValidatorNumber[T]) LessOrEqualTo(value T, template ...string) *ValidatorNumber[T]

Validate if a numeric value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := 2
Is(v.Number(quantity).LessOrEqualTo(2))

func (*ValidatorNumber[T]) LessThan

func (validator *ValidatorNumber[T]) LessThan(value T, template ...string) *ValidatorNumber[T]

Validate if a numeric value is less than another. This function internally uses the golang `<` operator. For example:

quantity := 2
Is(v.Number(quantity).LessThan(3))

func (*ValidatorNumber[T]) Not

func (validator *ValidatorNumber[T]) Not() *ValidatorNumber[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Number(0).Not().Zero()).Valid()

func (*ValidatorNumber[T]) Passing

func (validator *ValidatorNumber[T]) Passing(function func(v T) bool, template ...string) *ValidatorNumber[T]

Validate if a numeric value passes a custom function. For example:

quantity := 2
Is(v.Number(quantity).Passing((v int) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorNumber[T]) Zero

func (validator *ValidatorNumber[T]) Zero(template ...string) *ValidatorNumber[T]

Validate if a numeric value is zero.

For example:

Is(v.Number(0).Zero())

type ValidatorNumberP

type ValidatorNumberP[T TypeNumber] struct {
	// contains filtered or unexported fields
}

The Numeric pointer validator type that keeps its validator context.

func NumberP

func NumberP[T TypeNumber](value *T, nameAndTitle ...string) *ValidatorNumberP[T]

Receives a numeric pointer to validate.

The value can be any golang numeric pointer type (*int64, *int32, *float32, *uint, etc.) or a custom numeric type such as `type Level *int32;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorNumberP[T]) Between

func (validator *ValidatorNumberP[T]) Between(min T, max T, template ...string) *ValidatorNumberP[T]

Validate if the value of a numeric pointer is within a range (inclusive). For example:

n := 3
Is(v.NumberP(&n).Between(2,6))

func (*ValidatorNumberP[T]) Context

func (validator *ValidatorNumberP[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorNumberP[T]) EqualTo

func (validator *ValidatorNumberP[T]) EqualTo(value T, template ...string) *ValidatorNumberP[T]

Validate if a numeric pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := 2
Is(v.NumberP(quantity).Equal(2))

func (*ValidatorNumberP[T]) GreaterOrEqualTo

func (validator *ValidatorNumberP[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorNumberP[T]

Validate if a numeric pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := 3
Is(v.NumberP(&quantity).GreaterOrEqualTo(3))

func (*ValidatorNumberP[T]) GreaterThan

func (validator *ValidatorNumberP[T]) GreaterThan(value T, template ...string) *ValidatorNumberP[T]

Validate if a numeric pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := 3
Is(v.NumberP(&quantity).GreaterThan(2))

func (*ValidatorNumberP[T]) InSlice

func (validator *ValidatorNumberP[T]) InSlice(slice []T, template ...string) *ValidatorNumberP[T]

Validate if a numeric pointer value is present in a numeric slice. For example:

quantity := 3
validQuantities := []int{1,3,5}
Is(v.NumberP(&quantity).InSlice(validQuantities))

func (*ValidatorNumberP[T]) LessOrEqualTo

func (validator *ValidatorNumberP[T]) LessOrEqualTo(value T, template ...string) *ValidatorNumberP[T]

Validate if a numeric pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := 2
Is(v.NumberP(&quantity).LessOrEqualTo(2))

func (*ValidatorNumberP[T]) LessThan

func (validator *ValidatorNumberP[T]) LessThan(value T, template ...string) *ValidatorNumberP[T]

Validate if a numeric pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := 2
Is(v.NumberP(&quantity).LessThan(3))

func (*ValidatorNumberP[T]) Nil

func (validator *ValidatorNumberP[T]) Nil(template ...string) *ValidatorNumberP[T]

Validate if a numeric pointer value is nil.

For example:

var quantity *int
Is(v.NumberP(quantity).Nil()) // Will be true

func (*ValidatorNumberP[T]) Not

func (validator *ValidatorNumberP[T]) Not() *ValidatorNumberP[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := 0
Is(v.NumberP(&n).Not().Zero()).Valid()

func (*ValidatorNumberP[T]) Passing

func (validator *ValidatorNumberP[T]) Passing(function func(v *T) bool, template ...string) *ValidatorNumberP[T]

Validate if a numeric pointer value passes a custom function. For example:

quantity := 2
Is(v.NumberP(&quantity).Passing((v *int) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorNumberP[T]) Zero

func (validator *ValidatorNumberP[T]) Zero(template ...string) *ValidatorNumberP[T]

Validate if a numeric pointer value is zero.

For example:

n := 0
Is(v.NumberP(&n).Zero())

func (*ValidatorNumberP[T]) ZeroOrNil

func (validator *ValidatorNumberP[T]) ZeroOrNil(template ...string) *ValidatorNumberP[T]

Validate if a numeric pointer value is zero or nil.

For example:

var _quantity *int
Is(v.NumberP(_quantity).ZeroOrNil()) // Will be true

type ValidatorRune

type ValidatorRune[T ~rune] struct {
	// contains filtered or unexported fields
}

The rune validator type that keeps its validator context.

func Rune

func Rune[T ~rune](value T, nameAndTitle ...string) *ValidatorRune[T]

func (*ValidatorRune[T]) Between

func (validator *ValidatorRune[T]) Between(min T, max T, template ...string) *ValidatorRune[T]

Validate if the rune is within a range (inclusive). For example:

Is(v.Rune(rune(3)).Between(rune(2),rune(6)))

func (*ValidatorRune[T]) Context

func (validator *ValidatorRune[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorRune[T]) EqualTo

func (validator *ValidatorRune[T]) EqualTo(value T, template ...string) *ValidatorRune[T]

Validate if the rune value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := rune(2)
Is(v.Rune(quantity).Equal(rune(2)))

func (*ValidatorRune[T]) GreaterOrEqualTo

func (validator *ValidatorRune[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorRune[T]

Validate if the rune value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := rune(3)
Is(v.Rune(quantity).GreaterOrEqualTo(rune(3)))

func (*ValidatorRune[T]) GreaterThan

func (validator *ValidatorRune[T]) GreaterThan(value T, template ...string) *ValidatorRune[T]

Validate if the rune value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := rune(3)
Is(v.Rune(quantity).GreaterThan(rune(2)))

func (*ValidatorRune[T]) InSlice

func (validator *ValidatorRune[T]) InSlice(slice []T, template ...string) *ValidatorRune[T]

Validate if the rune value is present in the rune slice. For example:

quantity := rune(3)
validQuantities := []rune{1,3,5}
Is(v.Rune(quantity).InSlice(validQuantities))

func (*ValidatorRune[T]) LessOrEqualTo

func (validator *ValidatorRune[T]) LessOrEqualTo(value T, template ...string) *ValidatorRune[T]

Validate if the rune value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := rune(2)
Is(v.Rune(quantity).LessOrEqualTo(rune(2)))

func (*ValidatorRune[T]) LessThan

func (validator *ValidatorRune[T]) LessThan(value T, template ...string) *ValidatorRune[T]

Validate if the rune value is less than another. This function internally uses the golang `<` operator. For example:

quantity := rune(2)
Is(v.Rune(quantity).LessThan(rune(3)))

func (*ValidatorRune[T]) Not

func (validator *ValidatorRune[T]) Not() *ValidatorRune[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Rune(rune(0)).Not().Zero()).Valid()

func (*ValidatorRune[T]) Passing

func (validator *ValidatorRune[T]) Passing(function func(v T) bool, template ...string) *ValidatorRune[T]

Validate if the rune value passes a custom function. For example:

quantity := rune(2)
Is(v.Rune(quantity).Passing((v rune) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorRune[T]) Zero

func (validator *ValidatorRune[T]) Zero(template ...string) *ValidatorRune[T]

Validate if the rune value is zero.

For example:

Is(v.Rune(rune(0)).Zero())

type ValidatorRuneP

type ValidatorRuneP[T ~rune] struct {
	// contains filtered or unexported fields
}

The rune pointer validator type that keeps its validator context.

func RuneP

func RuneP[T ~rune](value *T, nameAndTitle ...string) *ValidatorRuneP[T]

Receives the rune pointer to validate.

The value also can be a custom rune type such as `type Level *rune;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorRuneP[T]) Between

func (validator *ValidatorRuneP[T]) Between(min T, max T, template ...string) *ValidatorRuneP[T]

Validate if the value of the rune pointer is within a range (inclusive). For example:

n := rune(3)
Is(v.RuneP(&n).Between(rune(2),rune(6)))

func (*ValidatorRuneP[T]) Context

func (validator *ValidatorRuneP[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorRuneP[T]) EqualTo

func (validator *ValidatorRuneP[T]) EqualTo(value T, template ...string) *ValidatorRuneP[T]

Validate if the rune pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := rune(2)
Is(v.RuneP(quantity).Equal(rune(2)))

func (*ValidatorRuneP[T]) GreaterOrEqualTo

func (validator *ValidatorRuneP[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorRuneP[T]

Validate if the rune pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := rune(3)
Is(v.RuneP(&quantity).GreaterOrEqualTo(rune(3)))

func (*ValidatorRuneP[T]) GreaterThan

func (validator *ValidatorRuneP[T]) GreaterThan(value T, template ...string) *ValidatorRuneP[T]

Validate if the rune pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := rune(3)
Is(v.RuneP(&quantity).GreaterThan(rune(2)))

func (*ValidatorRuneP[T]) InSlice

func (validator *ValidatorRuneP[T]) InSlice(slice []T, template ...string) *ValidatorRuneP[T]

Validate if the rune pointer value is present in a numeric slice. For example:

quantity := rune(3)
validQuantities := []rune{1,3,5}
Is(v.RuneP(&quantity).InSlice(validQuantities))

func (*ValidatorRuneP[T]) LessOrEqualTo

func (validator *ValidatorRuneP[T]) LessOrEqualTo(value T, template ...string) *ValidatorRuneP[T]

Validate if the rune pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := rune(2)
Is(v.RuneP(&quantity).LessOrEqualTo(rune(2)))

func (*ValidatorRuneP[T]) LessThan

func (validator *ValidatorRuneP[T]) LessThan(value T, template ...string) *ValidatorRuneP[T]

Validate if the rune pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := rune(2)
Is(v.RuneP(&quantity).LessThan(rune(3)))

func (*ValidatorRuneP[T]) Nil

func (validator *ValidatorRuneP[T]) Nil(template ...string) *ValidatorRuneP[T]

Validate if the rune pointer value is nil.

For example:

var quantity *rune
Is(v.RuneP(quantity).Nil()) // Will be true

func (*ValidatorRuneP[T]) Not

func (validator *ValidatorRuneP[T]) Not() *ValidatorRuneP[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := rune(0)
Is(v.RuneP(&n).Not().Zero()).Valid()

func (*ValidatorRuneP[T]) Passing

func (validator *ValidatorRuneP[T]) Passing(function func(v *T) bool, template ...string) *ValidatorRuneP[T]

Validate if the rune pointer value passes a custom function. For example:

quantity := rune(2)
Is(v.RuneP(&quantity).Passing((v *rune) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorRuneP[T]) Zero

func (validator *ValidatorRuneP[T]) Zero(template ...string) *ValidatorRuneP[T]

Validate if the rune pointer value is zero.

For example:

n := rune(0)
Is(v.RuneP(&n).Zero())

func (*ValidatorRuneP[T]) ZeroOrNil

func (validator *ValidatorRuneP[T]) ZeroOrNil(template ...string) *ValidatorRuneP[T]

Validate if the rune pointer value is zero or nil.

For example:

var _quantity *rune
Is(v.RuneP(_quantity).ZeroOrNil()) // Will be true

type ValidatorString

type ValidatorString[T ~string] struct {
	// contains filtered or unexported fields
}

The `ValidatorString` provides functions for setting validation rules for a string value type, or a custom type based on a string.

func String

func String[T ~string](value T, nameAndTitle ...string) *ValidatorString[T]

func (*ValidatorString[T]) Between

func (validator *ValidatorString[T]) Between(min T, max T, template ...string) *ValidatorString[T]

Validate if the value of a string is within a range (inclusive). For example:

slug := "ab"
Is(v.String(slug).Between("ab","ac"))

func (*ValidatorString[T]) Blank

func (validator *ValidatorString[T]) Blank(template ...string) *ValidatorString[T]

Validate if a string value is blank. Blank will be true if the length of the string is zero or if the string only has spaces. For example:

Is(v.String("").Empty()) // Will be true
Is(v.String(" ").Empty()) // Will be true

func (*ValidatorString[T]) Context

func (validator *ValidatorString[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorString[T]) Empty

func (validator *ValidatorString[T]) Empty(template ...string) *ValidatorString[T]

Validate if a string value is empty. Return false if the length of the string is greater than zero, even if the string has only spaces.

For checking if the string has only spaces, use the function `Blank()` instead. For example:

Is(v.String("").Empty()) // Will be true
Is(v.String(" ").Empty()) // Will be false

func (*ValidatorString[T]) EqualTo

func (validator *ValidatorString[T]) EqualTo(value T, template ...string) *ValidatorString[T]

Validate if a string value is equal to another. This function internally uses the golang `==` operator. For example:

status := "running"
Is(v.String(status).Equal("running"))

func (*ValidatorString[T]) GreaterOrEqualTo

func (validator *ValidatorString[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorString[T]

Validate if a string value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

section := "bc"
Is(v.String(section).GreaterOrEqualTo("bc"))

func (*ValidatorString[T]) GreaterThan

func (validator *ValidatorString[T]) GreaterThan(value T, template ...string) *ValidatorString[T]

Validate if a string value is greater than another. This function internally uses the golang `>` operator. For example:

section := "bb"
Is(v.String(section).GreaterThan("ba"))

func (*ValidatorString[T]) InSlice

func (validator *ValidatorString[T]) InSlice(slice []T, template ...string) *ValidatorString[T]

Validate if a string is present in a string slice. For example:

status := "idle"
validStatus := []string{"idle", "paused", "stopped"}
Is(v.String(status).InSlice(validStatus))

func (*ValidatorString[T]) LessOrEqualTo

func (validator *ValidatorString[T]) LessOrEqualTo(value T, template ...string) *ValidatorString[T]

Validate if a string value is less than or equal to another. This function internally uses the golang `<=` operator to compare two strings. For example:

section := "bc"
Is(v.String(section).LessOrEqualTo("bc"))

func (*ValidatorString[T]) LessThan

func (validator *ValidatorString[T]) LessThan(value T, template ...string) *ValidatorString[T]

Validate if a string value is less than another. This function internally uses the golang `<` operator. For example:

section := "bb"
Is(v.String(section).LessThan("bc"))

func (*ValidatorString[T]) MatchingTo

func (validator *ValidatorString[T]) MatchingTo(regex *regexp.Regexp, template ...string) *ValidatorString[T]

Validate if a string matches a regular expression. For example:

status := "pre-approved"
regex, _ := regexp.Compile("pre-.+")
Is(v.String(status).MatchingTo(regex))

func (*ValidatorString[T]) MaxLength

func (validator *ValidatorString[T]) MaxLength(length int, template ...string) *ValidatorString[T]

Validate the maximum length of a string. For example:

slug := "myname"
Is(v.String(slug).MaxLength(6))

func (*ValidatorString[T]) MinLength

func (validator *ValidatorString[T]) MinLength(length int, template ...string) *ValidatorString[T]

Validate the minimum length of a string. For example:

slug := "myname"
Is(v.String(slug).MinLength(6))

func (*ValidatorString[T]) Not

func (validator *ValidatorString[T]) Not() *ValidatorString[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Blank() function
Is(v.String("").Not().Blank()).Valid()

func (*ValidatorString[T]) OfLength

func (validator *ValidatorString[T]) OfLength(length int, template ...string) *ValidatorString[T]

Validate the length of a string. For example:

slug := "myname"
Is(v.String(slug).OfLength(6))

func (*ValidatorString[T]) OfLengthBetween

func (validator *ValidatorString[T]) OfLengthBetween(min int, max int, template ...string) *ValidatorString[T]

Validate if the length of a string is within a range (inclusive). For example:

slug := "myname"
Is(v.String(slug).OfLengthBetween(2,6))

func (*ValidatorString[T]) Passing

func (validator *ValidatorString[T]) Passing(function func(v0 T) bool, template ...string) *ValidatorString[T]

Validate if a string value passes a custom function. For example:

status := ""
Is(v.String(status).Passing((v string) bool {
	return v == getNewStatus()
})

type ValidatorStringP

type ValidatorStringP[T ~string] struct {
	// contains filtered or unexported fields
}

The String pointer validator type that keeps its validator context.

func StringP

func StringP[T ~string](value *T, nameAndTitle ...string) *ValidatorStringP[T]

func (*ValidatorStringP[T]) Between

func (validator *ValidatorStringP[T]) Between(min T, max T, template ...string) *ValidatorStringP[T]

Validate if the value of a string is in a range (inclusive). For example:

slug := "myname"
Is(v.StringP(&slug).Between(2,6))

func (*ValidatorStringP[T]) Blank

func (validator *ValidatorStringP[T]) Blank(template ...string) *ValidatorStringP[T]

Validate if a string value is blank. Blank will be true if the length of the string is zero or if the string only has spaces. For example:

status := ""
Is(v.StringP(&status).Blank()) // Will be true
status = " "
Is(v.StringP(&status).Blank()) // Will be true

func (*ValidatorStringP[T]) BlankOrNil

func (validator *ValidatorStringP[T]) BlankOrNil(template ...string) *ValidatorStringP[T]

Validate if a string value is blank or nil. Blank will be true if the length of the string is zero or if the string only has spaces. For example:

status := ""
Is(v.StringP(&status).BlankOrNil()) // Will be true
status = " "
Is(v.StringP(&status).BlankOrNil()) // Will be true
var _status *string
Is(v.StringP(_status).BlankOrNil()) // Will be true

func (*ValidatorStringP[T]) Context

func (validator *ValidatorStringP[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorStringP[T]) Empty

func (validator *ValidatorStringP[T]) Empty(template ...string) *ValidatorStringP[T]

Validate if a string value is empty. Empty will be false if the length of the string is greater than zero, even if the string has only spaces. For checking if the string has only spaces, uses the function `Blank()` instead. For example:

status := ""
Is(v.StringP(&status).Empty()) // Will be true
status = " "
Is(v.StringP(&status).Empty()) // Will be false

func (*ValidatorStringP[T]) EmptyOrNil

func (validator *ValidatorStringP[T]) EmptyOrNil(template ...string) *ValidatorStringP[T]

Validate if a string value is empty or nil. Empty will be false if the length of the string is greater than zero, even if the string has only spaces. For checking if the string has only spaces, uses the function `BlankOrNil()` instead. For example:

status := ""
Is(v.StringP(&status).EmptyOrNil()) // Will be true
status = " "
Is(v.StringP(&status).EmptyOrNil()) // Will be false
var _status *string
Is(v.StringP(_status).EmptyOrNil()) // Will be true

func (*ValidatorStringP[T]) EqualTo

func (validator *ValidatorStringP[T]) EqualTo(value T, template ...string) *ValidatorStringP[T]

Validate if the value of a string pointer is equal to a another value. For example:

status := "running"
Is(v.StringP(&status).Equal("running"))

func (*ValidatorStringP[T]) GreaterOrEqualTo

func (validator *ValidatorStringP[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorStringP[T]

func (*ValidatorStringP[T]) GreaterThan

func (validator *ValidatorStringP[T]) GreaterThan(value T, template ...string) *ValidatorStringP[T]

Validate if a string value is greater than another. This function internally uses the golang `>` operator. For example:

section := "bb"
Is(v.StringP(&section).GreaterThan("ba"))

func (*ValidatorStringP[T]) InSlice

func (validator *ValidatorStringP[T]) InSlice(slice []T, template ...string) *ValidatorStringP[T]

Validate if the value of a string pointer is present in a string slice. For example:

status := "idle"
validStatus := []string{"idle", "paused", "stopped"}
Is(v.StringP(&status).InSlice(validStatus))

func (*ValidatorStringP[T]) LessOrEqualTo

func (validator *ValidatorStringP[T]) LessOrEqualTo(value T, template ...string) *ValidatorStringP[T]

Validate if a string value is less or equal to another. This function internally uses the golang `<=` operator to compare two strings. For example:

section := "bc"
Is(v.StringP(&section).LessOrEqualTo("bc"))

func (*ValidatorStringP[T]) LessThan

func (validator *ValidatorStringP[T]) LessThan(value T, template ...string) *ValidatorStringP[T]

Validate if a string value is less than another. This function internally uses the golang `<` operator. For example:

section := "bb"
Is(v.StringP(&section).LessThan("bc"))

func (*ValidatorStringP[T]) MatchingTo

func (validator *ValidatorStringP[T]) MatchingTo(regex *regexp.Regexp, template ...string) *ValidatorStringP[T]

Validate if the value of a string pointer match a regular expression. For example:

status := "pre-approved"
regex, _ := regexp.Compile("pre-.+")
Is(v.StringP(&status).MatchingTo(regex))

func (*ValidatorStringP[T]) MaxLength

func (validator *ValidatorStringP[T]) MaxLength(length int, template ...string) *ValidatorStringP[T]

Validate if the maximum length of a string pointer's value. For example:

slug := "myname"
Is(v.StringP(&slug).MaxLength(6))

func (*ValidatorStringP[T]) MinLength

func (validator *ValidatorStringP[T]) MinLength(length int, template ...string) *ValidatorStringP[T]

Validate the minimum length of a string pointer's value For example:

slug := "myname"
Is(v.StringP(&slug).MinLength(6))

func (*ValidatorStringP[T]) Nil

func (validator *ValidatorStringP[T]) Nil(template ...string) *ValidatorStringP[T]

Validate if a string pointer is nil. For example:

var status *string
Is(v.StringP(status).Nil())

func (*ValidatorStringP[T]) Not

func (validator *ValidatorStringP[T]) Not() *ValidatorStringP[T]

Invert the logical value associated to the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Blank() function
status := ""
Is(v.StringP(&status).Not().Blank()).Valid()

func (*ValidatorStringP[T]) OfLength

func (validator *ValidatorStringP[T]) OfLength(length int, template ...string) *ValidatorStringP[T]

Validate the length of a string pointer's value. For example:

slug := "myname"
Is(v.StringP(&slug).OfLength(6))

func (*ValidatorStringP[T]) OfLengthBetween

func (validator *ValidatorStringP[T]) OfLengthBetween(min int, max int, template ...string) *ValidatorStringP[T]

Validate if the length of a string pointer's value is in a range (inclusive). For example:

slug := "myname"
Is(v.StringP(&slug).OfLengthBetween(2,6))

func (*ValidatorStringP[T]) Passing

func (validator *ValidatorStringP[T]) Passing(function func(v0 *T) bool, template ...string) *ValidatorStringP[T]

Validate if a string pointer pass a custom function. For example:

status := ""
Is(v.StringP(&status).Passing((v string) bool {
	return v == getNewStatus()
})

type ValidatorUint16

type ValidatorUint16[T ~uint16] struct {
	// contains filtered or unexported fields
}

The uint16 validator type that keeps its validator context.

func Uint16

func Uint16[T ~uint16](value T, nameAndTitle ...string) *ValidatorUint16[T]

func (*ValidatorUint16[T]) Between

func (validator *ValidatorUint16[T]) Between(min T, max T, template ...string) *ValidatorUint16[T]

Validate if the uint16 is within a range (inclusive). For example:

Is(v.Uint16(uint16(3)).Between(uint16(2),uint16(6)))

func (*ValidatorUint16[T]) Context

func (validator *ValidatorUint16[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorUint16[T]) EqualTo

func (validator *ValidatorUint16[T]) EqualTo(value T, template ...string) *ValidatorUint16[T]

Validate if the uint16 value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := uint16(2)
Is(v.Uint16(quantity).Equal(uint16(2)))

func (*ValidatorUint16[T]) GreaterOrEqualTo

func (validator *ValidatorUint16[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorUint16[T]

Validate if the uint16 value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := uint16(3)
Is(v.Uint16(quantity).GreaterOrEqualTo(uint16(3)))

func (*ValidatorUint16[T]) GreaterThan

func (validator *ValidatorUint16[T]) GreaterThan(value T, template ...string) *ValidatorUint16[T]

Validate if the uint16 value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := uint16(3)
Is(v.Uint16(quantity).GreaterThan(uint16(2)))

func (*ValidatorUint16[T]) InSlice

func (validator *ValidatorUint16[T]) InSlice(slice []T, template ...string) *ValidatorUint16[T]

Validate if the uint16 value is present in the uint16 slice. For example:

quantity := uint16(3)
validQuantities := []uint16{1,3,5}
Is(v.Uint16(quantity).InSlice(validQuantities))

func (*ValidatorUint16[T]) LessOrEqualTo

func (validator *ValidatorUint16[T]) LessOrEqualTo(value T, template ...string) *ValidatorUint16[T]

Validate if the uint16 value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := uint16(2)
Is(v.Uint16(quantity).LessOrEqualTo(uint16(2)))

func (*ValidatorUint16[T]) LessThan

func (validator *ValidatorUint16[T]) LessThan(value T, template ...string) *ValidatorUint16[T]

Validate if the uint16 value is less than another. This function internally uses the golang `<` operator. For example:

quantity := uint16(2)
Is(v.Uint16(quantity).LessThan(uint16(3)))

func (*ValidatorUint16[T]) Not

func (validator *ValidatorUint16[T]) Not() *ValidatorUint16[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Uint16(uint16(0)).Not().Zero()).Valid()

func (*ValidatorUint16[T]) Passing

func (validator *ValidatorUint16[T]) Passing(function func(v T) bool, template ...string) *ValidatorUint16[T]

Validate if the uint16 value passes a custom function. For example:

quantity := uint16(2)
Is(v.Uint16(quantity).Passing((v uint16) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorUint16[T]) Zero

func (validator *ValidatorUint16[T]) Zero(template ...string) *ValidatorUint16[T]

Validate if the uint16 value is zero.

For example:

Is(v.Uint16(uint16(0)).Zero())

type ValidatorUint16P

type ValidatorUint16P[T ~uint16] struct {
	// contains filtered or unexported fields
}

The uint16 pointer validator type that keeps its validator context.

func Uint16P

func Uint16P[T ~uint16](value *T, nameAndTitle ...string) *ValidatorUint16P[T]

Receives the uint16 pointer to validate.

The value also can be a custom uint16 type such as `type Level *uint16;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorUint16P[T]) Between

func (validator *ValidatorUint16P[T]) Between(min T, max T, template ...string) *ValidatorUint16P[T]

Validate if the value of the uint16 pointer is within a range (inclusive). For example:

n := uint16(3)
Is(v.Uint16P(&n).Between(uint16(2),uint16(6)))

func (*ValidatorUint16P[T]) Context

func (validator *ValidatorUint16P[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorUint16P[T]) EqualTo

func (validator *ValidatorUint16P[T]) EqualTo(value T, template ...string) *ValidatorUint16P[T]

Validate if the uint16 pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := uint16(2)
Is(v.Uint16P(quantity).Equal(uint16(2)))

func (*ValidatorUint16P[T]) GreaterOrEqualTo

func (validator *ValidatorUint16P[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorUint16P[T]

Validate if the uint16 pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := uint16(3)
Is(v.Uint16P(&quantity).GreaterOrEqualTo(uint16(3)))

func (*ValidatorUint16P[T]) GreaterThan

func (validator *ValidatorUint16P[T]) GreaterThan(value T, template ...string) *ValidatorUint16P[T]

Validate if the uint16 pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := uint16(3)
Is(v.Uint16P(&quantity).GreaterThan(uint16(2)))

func (*ValidatorUint16P[T]) InSlice

func (validator *ValidatorUint16P[T]) InSlice(slice []T, template ...string) *ValidatorUint16P[T]

Validate if the uint16 pointer value is present in a numeric slice. For example:

quantity := uint16(3)
validQuantities := []uint16{1,3,5}
Is(v.Uint16P(&quantity).InSlice(validQuantities))

func (*ValidatorUint16P[T]) LessOrEqualTo

func (validator *ValidatorUint16P[T]) LessOrEqualTo(value T, template ...string) *ValidatorUint16P[T]

Validate if the uint16 pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := uint16(2)
Is(v.Uint16P(&quantity).LessOrEqualTo(uint16(2)))

func (*ValidatorUint16P[T]) LessThan

func (validator *ValidatorUint16P[T]) LessThan(value T, template ...string) *ValidatorUint16P[T]

Validate if the uint16 pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := uint16(2)
Is(v.Uint16P(&quantity).LessThan(uint16(3)))

func (*ValidatorUint16P[T]) Nil

func (validator *ValidatorUint16P[T]) Nil(template ...string) *ValidatorUint16P[T]

Validate if the uint16 pointer value is nil.

For example:

var quantity *uint16
Is(v.Uint16P(quantity).Nil()) // Will be true

func (*ValidatorUint16P[T]) Not

func (validator *ValidatorUint16P[T]) Not() *ValidatorUint16P[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := uint16(0)
Is(v.Uint16P(&n).Not().Zero()).Valid()

func (*ValidatorUint16P[T]) Passing

func (validator *ValidatorUint16P[T]) Passing(function func(v *T) bool, template ...string) *ValidatorUint16P[T]

Validate if the uint16 pointer value passes a custom function. For example:

quantity := uint16(2)
Is(v.Uint16P(&quantity).Passing((v *uint16) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorUint16P[T]) Zero

func (validator *ValidatorUint16P[T]) Zero(template ...string) *ValidatorUint16P[T]

Validate if the uint16 pointer value is zero.

For example:

n := uint16(0)
Is(v.Uint16P(&n).Zero())

func (*ValidatorUint16P[T]) ZeroOrNil

func (validator *ValidatorUint16P[T]) ZeroOrNil(template ...string) *ValidatorUint16P[T]

Validate if the uint16 pointer value is zero or nil.

For example:

var _quantity *uint16
Is(v.Uint16P(_quantity).ZeroOrNil()) // Will be true

type ValidatorUint32

type ValidatorUint32[T ~uint32] struct {
	// contains filtered or unexported fields
}

The uint32 validator type that keeps its validator context.

func Uint32

func Uint32[T ~uint32](value T, nameAndTitle ...string) *ValidatorUint32[T]

func (*ValidatorUint32[T]) Between

func (validator *ValidatorUint32[T]) Between(min T, max T, template ...string) *ValidatorUint32[T]

Validate if the uint32 is within a range (inclusive). For example:

Is(v.Uint32(uint32(3)).Between(uint32(2),uint32(6)))

func (*ValidatorUint32[T]) Context

func (validator *ValidatorUint32[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorUint32[T]) EqualTo

func (validator *ValidatorUint32[T]) EqualTo(value T, template ...string) *ValidatorUint32[T]

Validate if the uint32 value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := uint32(2)
Is(v.Uint32(quantity).Equal(uint32(2)))

func (*ValidatorUint32[T]) GreaterOrEqualTo

func (validator *ValidatorUint32[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorUint32[T]

Validate if the uint32 value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := uint32(3)
Is(v.Uint32(quantity).GreaterOrEqualTo(uint32(3)))

func (*ValidatorUint32[T]) GreaterThan

func (validator *ValidatorUint32[T]) GreaterThan(value T, template ...string) *ValidatorUint32[T]

Validate if the uint32 value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := uint32(3)
Is(v.Uint32(quantity).GreaterThan(uint32(2)))

func (*ValidatorUint32[T]) InSlice

func (validator *ValidatorUint32[T]) InSlice(slice []T, template ...string) *ValidatorUint32[T]

Validate if the uint32 value is present in the uint32 slice. For example:

quantity := uint32(3)
validQuantities := []uint32{1,3,5}
Is(v.Uint32(quantity).InSlice(validQuantities))

func (*ValidatorUint32[T]) LessOrEqualTo

func (validator *ValidatorUint32[T]) LessOrEqualTo(value T, template ...string) *ValidatorUint32[T]

Validate if the uint32 value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := uint32(2)
Is(v.Uint32(quantity).LessOrEqualTo(uint32(2)))

func (*ValidatorUint32[T]) LessThan

func (validator *ValidatorUint32[T]) LessThan(value T, template ...string) *ValidatorUint32[T]

Validate if the uint32 value is less than another. This function internally uses the golang `<` operator. For example:

quantity := uint32(2)
Is(v.Uint32(quantity).LessThan(uint32(3)))

func (*ValidatorUint32[T]) Not

func (validator *ValidatorUint32[T]) Not() *ValidatorUint32[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Uint32(uint32(0)).Not().Zero()).Valid()

func (*ValidatorUint32[T]) Passing

func (validator *ValidatorUint32[T]) Passing(function func(v T) bool, template ...string) *ValidatorUint32[T]

Validate if the uint32 value passes a custom function. For example:

quantity := uint32(2)
Is(v.Uint32(quantity).Passing((v uint32) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorUint32[T]) Zero

func (validator *ValidatorUint32[T]) Zero(template ...string) *ValidatorUint32[T]

Validate if the uint32 value is zero.

For example:

Is(v.Uint32(uint32(0)).Zero())

type ValidatorUint32P

type ValidatorUint32P[T ~uint32] struct {
	// contains filtered or unexported fields
}

The uint32 pointer validator type that keeps its validator context.

func Uint32P

func Uint32P[T ~uint32](value *T, nameAndTitle ...string) *ValidatorUint32P[T]

Receives the uint32 pointer to validate.

The value also can be a custom uint32 type such as `type Level *uint32;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorUint32P[T]) Between

func (validator *ValidatorUint32P[T]) Between(min T, max T, template ...string) *ValidatorUint32P[T]

Validate if the value of the uint32 pointer is within a range (inclusive). For example:

n := uint32(3)
Is(v.Uint32P(&n).Between(uint32(2),uint32(6)))

func (*ValidatorUint32P[T]) Context

func (validator *ValidatorUint32P[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorUint32P[T]) EqualTo

func (validator *ValidatorUint32P[T]) EqualTo(value T, template ...string) *ValidatorUint32P[T]

Validate if the uint32 pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := uint32(2)
Is(v.Uint32P(quantity).Equal(uint32(2)))

func (*ValidatorUint32P[T]) GreaterOrEqualTo

func (validator *ValidatorUint32P[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorUint32P[T]

Validate if the uint32 pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := uint32(3)
Is(v.Uint32P(&quantity).GreaterOrEqualTo(uint32(3)))

func (*ValidatorUint32P[T]) GreaterThan

func (validator *ValidatorUint32P[T]) GreaterThan(value T, template ...string) *ValidatorUint32P[T]

Validate if the uint32 pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := uint32(3)
Is(v.Uint32P(&quantity).GreaterThan(uint32(2)))

func (*ValidatorUint32P[T]) InSlice

func (validator *ValidatorUint32P[T]) InSlice(slice []T, template ...string) *ValidatorUint32P[T]

Validate if the uint32 pointer value is present in a numeric slice. For example:

quantity := uint32(3)
validQuantities := []uint32{1,3,5}
Is(v.Uint32P(&quantity).InSlice(validQuantities))

func (*ValidatorUint32P[T]) LessOrEqualTo

func (validator *ValidatorUint32P[T]) LessOrEqualTo(value T, template ...string) *ValidatorUint32P[T]

Validate if the uint32 pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := uint32(2)
Is(v.Uint32P(&quantity).LessOrEqualTo(uint32(2)))

func (*ValidatorUint32P[T]) LessThan

func (validator *ValidatorUint32P[T]) LessThan(value T, template ...string) *ValidatorUint32P[T]

Validate if the uint32 pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := uint32(2)
Is(v.Uint32P(&quantity).LessThan(uint32(3)))

func (*ValidatorUint32P[T]) Nil

func (validator *ValidatorUint32P[T]) Nil(template ...string) *ValidatorUint32P[T]

Validate if the uint32 pointer value is nil.

For example:

var quantity *uint32
Is(v.Uint32P(quantity).Nil()) // Will be true

func (*ValidatorUint32P[T]) Not

func (validator *ValidatorUint32P[T]) Not() *ValidatorUint32P[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := uint32(0)
Is(v.Uint32P(&n).Not().Zero()).Valid()

func (*ValidatorUint32P[T]) Passing

func (validator *ValidatorUint32P[T]) Passing(function func(v *T) bool, template ...string) *ValidatorUint32P[T]

Validate if the uint32 pointer value passes a custom function. For example:

quantity := uint32(2)
Is(v.Uint32P(&quantity).Passing((v *uint32) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorUint32P[T]) Zero

func (validator *ValidatorUint32P[T]) Zero(template ...string) *ValidatorUint32P[T]

Validate if the uint32 pointer value is zero.

For example:

n := uint32(0)
Is(v.Uint32P(&n).Zero())

func (*ValidatorUint32P[T]) ZeroOrNil

func (validator *ValidatorUint32P[T]) ZeroOrNil(template ...string) *ValidatorUint32P[T]

Validate if the uint32 pointer value is zero or nil.

For example:

var _quantity *uint32
Is(v.Uint32P(_quantity).ZeroOrNil()) // Will be true

type ValidatorUint64

type ValidatorUint64[T ~uint64] struct {
	// contains filtered or unexported fields
}

The uint64 validator type that keeps its validator context.

func Uint64

func Uint64[T ~uint64](value T, nameAndTitle ...string) *ValidatorUint64[T]

func (*ValidatorUint64[T]) Between

func (validator *ValidatorUint64[T]) Between(min T, max T, template ...string) *ValidatorUint64[T]

Validate if the uint64 is within a range (inclusive). For example:

Is(v.Uint64(uint64(3)).Between(uint64(2),uint64(6)))

func (*ValidatorUint64[T]) Context

func (validator *ValidatorUint64[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorUint64[T]) EqualTo

func (validator *ValidatorUint64[T]) EqualTo(value T, template ...string) *ValidatorUint64[T]

Validate if the uint64 value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := uint64(2)
Is(v.Uint64(quantity).Equal(uint64(2)))

func (*ValidatorUint64[T]) GreaterOrEqualTo

func (validator *ValidatorUint64[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorUint64[T]

Validate if the uint64 value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := uint64(3)
Is(v.Uint64(quantity).GreaterOrEqualTo(uint64(3)))

func (*ValidatorUint64[T]) GreaterThan

func (validator *ValidatorUint64[T]) GreaterThan(value T, template ...string) *ValidatorUint64[T]

Validate if the uint64 value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := uint64(3)
Is(v.Uint64(quantity).GreaterThan(uint64(2)))

func (*ValidatorUint64[T]) InSlice

func (validator *ValidatorUint64[T]) InSlice(slice []T, template ...string) *ValidatorUint64[T]

Validate if the uint64 value is present in the uint64 slice. For example:

quantity := uint64(3)
validQuantities := []uint64{1,3,5}
Is(v.Uint64(quantity).InSlice(validQuantities))

func (*ValidatorUint64[T]) LessOrEqualTo

func (validator *ValidatorUint64[T]) LessOrEqualTo(value T, template ...string) *ValidatorUint64[T]

Validate if the uint64 value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := uint64(2)
Is(v.Uint64(quantity).LessOrEqualTo(uint64(2)))

func (*ValidatorUint64[T]) LessThan

func (validator *ValidatorUint64[T]) LessThan(value T, template ...string) *ValidatorUint64[T]

Validate if the uint64 value is less than another. This function internally uses the golang `<` operator. For example:

quantity := uint64(2)
Is(v.Uint64(quantity).LessThan(uint64(3)))

func (*ValidatorUint64[T]) Not

func (validator *ValidatorUint64[T]) Not() *ValidatorUint64[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Uint64(uint64(0)).Not().Zero()).Valid()

func (*ValidatorUint64[T]) Passing

func (validator *ValidatorUint64[T]) Passing(function func(v T) bool, template ...string) *ValidatorUint64[T]

Validate if the uint64 value passes a custom function. For example:

quantity := uint64(2)
Is(v.Uint64(quantity).Passing((v uint64) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorUint64[T]) Zero

func (validator *ValidatorUint64[T]) Zero(template ...string) *ValidatorUint64[T]

Validate if the uint64 value is zero.

For example:

Is(v.Uint64(uint64(0)).Zero())

type ValidatorUint64P

type ValidatorUint64P[T ~uint64] struct {
	// contains filtered or unexported fields
}

The uint64 pointer validator type that keeps its validator context.

func Uint64P

func Uint64P[T ~uint64](value *T, nameAndTitle ...string) *ValidatorUint64P[T]

Receives the uint64 pointer to validate.

The value also can be a custom uint64 type such as `type Level *uint64;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorUint64P[T]) Between

func (validator *ValidatorUint64P[T]) Between(min T, max T, template ...string) *ValidatorUint64P[T]

Validate if the value of the uint64 pointer is within a range (inclusive). For example:

n := uint64(3)
Is(v.Uint64P(&n).Between(uint64(2),uint64(6)))

func (*ValidatorUint64P[T]) Context

func (validator *ValidatorUint64P[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorUint64P[T]) EqualTo

func (validator *ValidatorUint64P[T]) EqualTo(value T, template ...string) *ValidatorUint64P[T]

Validate if the uint64 pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := uint64(2)
Is(v.Uint64P(quantity).Equal(uint64(2)))

func (*ValidatorUint64P[T]) GreaterOrEqualTo

func (validator *ValidatorUint64P[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorUint64P[T]

Validate if the uint64 pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := uint64(3)
Is(v.Uint64P(&quantity).GreaterOrEqualTo(uint64(3)))

func (*ValidatorUint64P[T]) GreaterThan

func (validator *ValidatorUint64P[T]) GreaterThan(value T, template ...string) *ValidatorUint64P[T]

Validate if the uint64 pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := uint64(3)
Is(v.Uint64P(&quantity).GreaterThan(uint64(2)))

func (*ValidatorUint64P[T]) InSlice

func (validator *ValidatorUint64P[T]) InSlice(slice []T, template ...string) *ValidatorUint64P[T]

Validate if the uint64 pointer value is present in a numeric slice. For example:

quantity := uint64(3)
validQuantities := []uint64{1,3,5}
Is(v.Uint64P(&quantity).InSlice(validQuantities))

func (*ValidatorUint64P[T]) LessOrEqualTo

func (validator *ValidatorUint64P[T]) LessOrEqualTo(value T, template ...string) *ValidatorUint64P[T]

Validate if the uint64 pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := uint64(2)
Is(v.Uint64P(&quantity).LessOrEqualTo(uint64(2)))

func (*ValidatorUint64P[T]) LessThan

func (validator *ValidatorUint64P[T]) LessThan(value T, template ...string) *ValidatorUint64P[T]

Validate if the uint64 pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := uint64(2)
Is(v.Uint64P(&quantity).LessThan(uint64(3)))

func (*ValidatorUint64P[T]) Nil

func (validator *ValidatorUint64P[T]) Nil(template ...string) *ValidatorUint64P[T]

Validate if the uint64 pointer value is nil.

For example:

var quantity *uint64
Is(v.Uint64P(quantity).Nil()) // Will be true

func (*ValidatorUint64P[T]) Not

func (validator *ValidatorUint64P[T]) Not() *ValidatorUint64P[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := uint64(0)
Is(v.Uint64P(&n).Not().Zero()).Valid()

func (*ValidatorUint64P[T]) Passing

func (validator *ValidatorUint64P[T]) Passing(function func(v *T) bool, template ...string) *ValidatorUint64P[T]

Validate if the uint64 pointer value passes a custom function. For example:

quantity := uint64(2)
Is(v.Uint64P(&quantity).Passing((v *uint64) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorUint64P[T]) Zero

func (validator *ValidatorUint64P[T]) Zero(template ...string) *ValidatorUint64P[T]

Validate if the uint64 pointer value is zero.

For example:

n := uint64(0)
Is(v.Uint64P(&n).Zero())

func (*ValidatorUint64P[T]) ZeroOrNil

func (validator *ValidatorUint64P[T]) ZeroOrNil(template ...string) *ValidatorUint64P[T]

Validate if the uint64 pointer value is zero or nil.

For example:

var _quantity *uint64
Is(v.Uint64P(_quantity).ZeroOrNil()) // Will be true

type ValidatorUint8

type ValidatorUint8[T ~uint8] struct {
	// contains filtered or unexported fields
}

The uint8 validator type that keeps its validator context.

func Uint8

func Uint8[T ~uint8](value T, nameAndTitle ...string) *ValidatorUint8[T]

func (*ValidatorUint8[T]) Between

func (validator *ValidatorUint8[T]) Between(min T, max T, template ...string) *ValidatorUint8[T]

Validate if the uint8 is within a range (inclusive). For example:

Is(v.Uint8(uint8(3)).Between(uint8(2),uint8(6)))

func (*ValidatorUint8[T]) Context

func (validator *ValidatorUint8[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorUint8[T]) EqualTo

func (validator *ValidatorUint8[T]) EqualTo(value T, template ...string) *ValidatorUint8[T]

Validate if the uint8 value is equal to another. This function internally uses the golang `==` operator. For example:

quantity := uint8(2)
Is(v.Uint8(quantity).Equal(uint8(2)))

func (*ValidatorUint8[T]) GreaterOrEqualTo

func (validator *ValidatorUint8[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorUint8[T]

Validate if the uint8 value is greater than or equal to another. This function internally uses the golang `>=` operator. For example:

quantity := uint8(3)
Is(v.Uint8(quantity).GreaterOrEqualTo(uint8(3)))

func (*ValidatorUint8[T]) GreaterThan

func (validator *ValidatorUint8[T]) GreaterThan(value T, template ...string) *ValidatorUint8[T]

Validate if the uint8 value is greater than another. This function internally uses the golang `>` operator. For example:

quantity := uint8(3)
Is(v.Uint8(quantity).GreaterThan(uint8(2)))

func (*ValidatorUint8[T]) InSlice

func (validator *ValidatorUint8[T]) InSlice(slice []T, template ...string) *ValidatorUint8[T]

Validate if the uint8 value is present in the uint8 slice. For example:

quantity := uint8(3)
validQuantities := []uint8{1,3,5}
Is(v.Uint8(quantity).InSlice(validQuantities))

func (*ValidatorUint8[T]) LessOrEqualTo

func (validator *ValidatorUint8[T]) LessOrEqualTo(value T, template ...string) *ValidatorUint8[T]

Validate if the uint8 value is less than or equal to another. This function internally uses the golang `<=` operator. For example:

quantity := uint8(2)
Is(v.Uint8(quantity).LessOrEqualTo(uint8(2)))

func (*ValidatorUint8[T]) LessThan

func (validator *ValidatorUint8[T]) LessThan(value T, template ...string) *ValidatorUint8[T]

Validate if the uint8 value is less than another. This function internally uses the golang `<` operator. For example:

quantity := uint8(2)
Is(v.Uint8(quantity).LessThan(uint8(3)))

func (*ValidatorUint8[T]) Not

func (validator *ValidatorUint8[T]) Not() *ValidatorUint8[T]

Invert the logical value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
Is(v.Uint8(uint8(0)).Not().Zero()).Valid()

func (*ValidatorUint8[T]) Passing

func (validator *ValidatorUint8[T]) Passing(function func(v T) bool, template ...string) *ValidatorUint8[T]

Validate if the uint8 value passes a custom function. For example:

quantity := uint8(2)
Is(v.Uint8(quantity).Passing((v uint8) bool {
	return v == getAllowedQuantity()
})

func (*ValidatorUint8[T]) Zero

func (validator *ValidatorUint8[T]) Zero(template ...string) *ValidatorUint8[T]

Validate if the uint8 value is zero.

For example:

Is(v.Uint8(uint8(0)).Zero())

type ValidatorUint8P

type ValidatorUint8P[T ~uint8] struct {
	// contains filtered or unexported fields
}

The uint8 pointer validator type that keeps its validator context.

func Uint8P

func Uint8P[T ~uint8](value *T, nameAndTitle ...string) *ValidatorUint8P[T]

Receives the uint8 pointer to validate.

The value also can be a custom uint8 type such as `type Level *uint8;`

Optionally, the function can receive a name and title, in that order, to be used in the error messages. A `value_%N“ pattern is used as a name in error messages if a name and title are not supplied; for example: value_0. When the name is provided but not the title, then the name is humanized to be used as the title as well; for example the name `phone_number` will be humanized as `Phone Number`

func (*ValidatorUint8P[T]) Between

func (validator *ValidatorUint8P[T]) Between(min T, max T, template ...string) *ValidatorUint8P[T]

Validate if the value of the uint8 pointer is within a range (inclusive). For example:

n := uint8(3)
Is(v.Uint8P(&n).Between(uint8(2),uint8(6)))

func (*ValidatorUint8P[T]) Context

func (validator *ValidatorUint8P[T]) Context() *ValidatorContext

Return the context of the validator. The context is useful to create a custom validator by extending this validator.

func (*ValidatorUint8P[T]) EqualTo

func (validator *ValidatorUint8P[T]) EqualTo(value T, template ...string) *ValidatorUint8P[T]

Validate if the uint8 pointer value is equal to another value. This function internally uses the golang `==` operator. For example:

quantity := uint8(2)
Is(v.Uint8P(quantity).Equal(uint8(2)))

func (*ValidatorUint8P[T]) GreaterOrEqualTo

func (validator *ValidatorUint8P[T]) GreaterOrEqualTo(value T, template ...string) *ValidatorUint8P[T]

Validate if the uint8 pointer value is greater than or equal to another value. This function internally uses the golang `>=` operator. For example:

quantity := uint8(3)
Is(v.Uint8P(&quantity).GreaterOrEqualTo(uint8(3)))

func (*ValidatorUint8P[T]) GreaterThan

func (validator *ValidatorUint8P[T]) GreaterThan(value T, template ...string) *ValidatorUint8P[T]

Validate if the uint8 pointer value is greater than another value. This function internally uses the golang `>` operator. For example:

quantity := uint8(3)
Is(v.Uint8P(&quantity).GreaterThan(uint8(2)))

func (*ValidatorUint8P[T]) InSlice

func (validator *ValidatorUint8P[T]) InSlice(slice []T, template ...string) *ValidatorUint8P[T]

Validate if the uint8 pointer value is present in a numeric slice. For example:

quantity := uint8(3)
validQuantities := []uint8{1,3,5}
Is(v.Uint8P(&quantity).InSlice(validQuantities))

func (*ValidatorUint8P[T]) LessOrEqualTo

func (validator *ValidatorUint8P[T]) LessOrEqualTo(value T, template ...string) *ValidatorUint8P[T]

Validate if the uint8 pointer value is less than or equal to another value. This function internally uses the golang `<=` operator. For example:

quantity := uint8(2)
Is(v.Uint8P(&quantity).LessOrEqualTo(uint8(2)))

func (*ValidatorUint8P[T]) LessThan

func (validator *ValidatorUint8P[T]) LessThan(value T, template ...string) *ValidatorUint8P[T]

Validate if the uint8 pointer value is less than another value. This function internally uses the golang `<` operator. For example:

quantity := uint8(2)
Is(v.Uint8P(&quantity).LessThan(uint8(3)))

func (*ValidatorUint8P[T]) Nil

func (validator *ValidatorUint8P[T]) Nil(template ...string) *ValidatorUint8P[T]

Validate if the uint8 pointer value is nil.

For example:

var quantity *uint8
Is(v.Uint8P(quantity).Nil()) // Will be true

func (*ValidatorUint8P[T]) Not

func (validator *ValidatorUint8P[T]) Not() *ValidatorUint8P[T]

Invert the boolean value associated with the next validator function. For example:

// It will return false because Not() inverts the boolean value associated with the Zero() function
n := uint8(0)
Is(v.Uint8P(&n).Not().Zero()).Valid()

func (*ValidatorUint8P[T]) Passing

func (validator *ValidatorUint8P[T]) Passing(function func(v *T) bool, template ...string) *ValidatorUint8P[T]

Validate if the uint8 pointer value passes a custom function. For example:

quantity := uint8(2)
Is(v.Uint8P(&quantity).Passing((v *uint8) bool {
	return *v == getAllowedQuantity()
})

func (*ValidatorUint8P[T]) Zero

func (validator *ValidatorUint8P[T]) Zero(template ...string) *ValidatorUint8P[T]

Validate if the uint8 pointer value is zero.

For example:

n := uint8(0)
Is(v.Uint8P(&n).Zero())

func (*ValidatorUint8P[T]) ZeroOrNil

func (validator *ValidatorUint8P[T]) ZeroOrNil(template ...string) *ValidatorUint8P[T]

Validate if the uint8 pointer value is zero or nil.

For example:

var _quantity *uint8
Is(v.Uint8P(_quantity).ZeroOrNil()) // Will be true

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL