Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator Base Module #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Validator Base Module #14

wants to merge 2 commits into from

Conversation

poncho
Copy link

@poncho poncho commented Feb 10, 2023

Context

Instead of having to create a function for each different document we need for every country, we added a base module that creates this function for each specified document in the use command.

Example

  use Bali.Validator,
    country: :pt,
    documents: %{
      nif: ~r/^\d{9}$/
    }

This enables the specific country validators to only use this module
specifying the required documents without having to create a
`validate/2` function for every document.

use Bali.Validator,
  country: :pt,
  documents: %{
    nif: ~r/^\d{9}$/
  }

regex ->
if Regex.match?(regex, value) do
true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devolver true puede generar confusión porque se puede asumir que en caso contrario se va a devolver false, se podría quedar como :ok 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ates regresaba un tipo {:ok, String.t()}. No sería bueno mantenerlo?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Con lo que se habló en el canal se dejó que se mantenga :valid | {:error, String.t()} como spec de respuesta

como fiscales, segun lo revisado con operaciones

## Ejemplos:
Validator for Portuguese personal and tax identifications.any()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.any() ?


regex ->
if Regex.match?(regex, value) do
true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ates regresaba un tipo {:ok, String.t()}. No sería bueno mantenerlo?

lib/validators/portugal.ex Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants