Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 740 Bytes

max.md

File metadata and controls

30 lines (22 loc) · 740 Bytes

Max Checker

The max checker checks if the given int or float value is less than the given maximum. If the value is above the maximum, the checker will return the NOT_MAX result. Here is an example:

type Order struct {
  Quantity int `checkers:"max:10"`
}

order := &Order{
  Quantity: 5,
}

mistakes, valid := checker.Check(order)
if !valid {
  // Send the mistakes back to the user
}

In your custom checkers, you can call the max checker function IsMax to validate the user input. Here is an example:

quantity := 5

result := checker.IsMax(quantity, 10)

if result != checker.ResultValid {
  // Send the mistakes back to the user
}