View Source Shapex.Types.Integer (shapex v0.1.0)

This module provides a type for validating integers.

Existing validations:

  • :gt - greater than
  • :gte - greater than or equal to
  • :lt - less than
  • :lte - less than or equal to
  • :eq - equal
  • :neq - not equal
  • :in - checks if the value is in a list
  • :not_in - checks if the value is not in a list

It's better to use the Shapex.Types.integer/1 function to create a schema, since it covers implementation details and provides a more user-friendly API.

Summary

Types

@type t() :: %Shapex.Types.Integer{validations: [validation_rules()]}
@type target(a) :: a | {a, String.t()}
@type validation_rules() ::
  {:gt, target(integer())}
  | {:gte, target(integer())}
  | {:lt, target(integer())}
  | {:lte, target(integer())}
  | {:eq, target(integer())}
  | {:neq, target(integer())}
  | {:in, target([integer()])}
  | {:not_in, target([integer()])}