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

Is 'utils' belongs to this library ? #7

Open
Nesqwik opened this issue Aug 18, 2021 · 4 comments
Open

Is 'utils' belongs to this library ? #7

Nesqwik opened this issue Aug 18, 2021 · 4 comments
Labels
help wanted Extra attention is needed invalid This doesn't seem right question Further information is requested

Comments

@Nesqwik
Copy link
Member

Nesqwik commented Aug 18, 2021

There is a folder 'utils' that give some helpers to :

  • parse a color
  • validate textfield input (password/email)

The color parser is not used by the library. It is just exposed as part of the lib.
The validator is partially used by the lenra_text_form_field.dart component to check the value of the input based of the type parameter (email or password).

I think we can safely remove the color parser but i'm not sure about the validator :

  • Is it our job to check the value of the input ? If not, we should remove the validator.
  • If it is our job, we should provide a way for the user to completely override the validator (not just add on top of the existing validator).
  • Should we add more types in the futur ? (phone number, address...)

@lenra-io/lenra any thought ?

@Nesqwik Nesqwik added help wanted Extra attention is needed invalid This doesn't seem right question Further information is requested labels Aug 18, 2021
@jonas-martinez
Copy link
Contributor

I too think that we can safely remove the color parser.
For the form validators I think that it should not be here in its actual state for the following reason : The validation strictly depends on the user's needs, for example I don't think that everyone wants to have the same password validator as ours.
We could still give some generic validators to compose bigger ones such as "checkLength" or "checkNotEmpty", what do you think?

@pichoemr
Copy link
Contributor

I also think we can remove ColorParser.
For form validators I agree with Jonas, we can keep the generic validators like checkLength/checkNotEmpty/checkGitFormat? and use the LenraTextFormFieldTypes for our validators, for example we can move checkPassword and checkEmail directly in our email and password validator.

@Nesqwik
Copy link
Member Author

Nesqwik commented Aug 18, 2021

Imo there is too much issue with the validators :

  • It is highly opinionated (at least for the "password" check)
  • There is no 100% accurate regex to check the email
  • The usage is also opinionated (see the base usage)
  • We must provide translations for error message AND a way for third part user to override them.

I think it is out of the scope for this library.

@taorepoara what is your opinion ?

@taorepoara
Copy link
Member

I think that we should re-think the validator management in order to manage validation level (success, info, warning, error). We'd rather manage only basic validators (length and regex) and permit the users to implement their own validators with the same base usage as Flutter do.

We can also let the users manage the validator results to build a custom UI by defining a callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed invalid This doesn't seem right question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants