View Source Shapex.Types.Float (shapex v0.3.1)

This module provides a type for validating floats.

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.float/1 function to create a schema, since it covers implementation details and provides a more user-friendly API.

Summary

Types

@type float_list_or_tuple() :: [float()] | {[float()], String.t()}
@type float_or_tuple() :: float() | {float(), String.t()}
@type t() :: %Shapex.Types.Float{validations: [validations()]}
@type validations() ::
  {:lt, float_or_tuple()}
  | {:lte, float_or_tuple()}
  | {:gt, float_or_tuple()}
  | {:gte, float_or_tuple()}
  | {:eq, float_or_tuple()}
  | {:neq, float_or_tuple()}
  | {:in, float_list_or_tuple()}
  | {:not_in, float_list_or_tuple()}

Functions

@spec validate(t(), float()) :: :ok | {:error, map()}

Callback implementation for Shapex.Type.validate/2.