Skip to content

would be possible to halt validation if a single error ocurr? (map or array validation) #27

@henriquesati

Description

@henriquesati

Hi, if I have a input with multiple keys, it would be possible to stop the validation if a given key fails validation? I need to perform api calls on subsequent keys, so it would be a waste to do it if x or z key->values fails
example:

 %{
              "chain" => [required: true, custom: validate_supported_chain(), type: :string],
              "coin" => [required: true, type: :string, max: 20],
              "payload" => [required: true, type: :string, custom: validate_qrcode(), max: 180],
    }
         
           def validate_supported_chain() do
                fn %{value: value} ->
                  case Map.fetch(@supported_chain, String.downcase(value)) do
                  {:ok, value} -> Validate.Validator.success(value)
                  :error -> Validate.Validator.halt("rede não suportada")
          end
       end
  end
  

if validate_qrcode makes an api call, would be possible to avoid this api call if supported_chain fails?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions