fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.15k stars 1.4k forks source link

META: List of validators to consider adding #1268

Open Jacalz opened 4 years ago

Jacalz commented 4 years ago

Is your feature request related to a problem? Please describe:

Input validation is a very important part of application design in order to create secure applications. We should therefore provide more out of the box validators for developers to utilize inside their code.

Is it possible to construct a solution with the existing API?

Yes. See #1267 for moving them out of the top level package.

Describe the solution you'd like to see:

Please comment on this issue with example of validators that you think would make sense. We can update this list as we go.

Validators to consider:

stuartmscott commented 4 years ago
andydotxyz commented 4 years ago

Maybe ValidatorList sounds more like a group of validations than ListValidator which sounds like checking input is a list.

Alternatively (as it’s now in ‘data/validator’) how about ‘validator.RequireAll’?

fpabl0 commented 3 years ago

This would be a great addition. Until now, I have been using my own package with common validators to develop Fyne apps faster, but there would be really good if it comes by default :)

For ValidatorList, I use:

validator.NewGroup(validators ...fyne.StringValidator) fyne.StringValidator

Then for common ones:

validator.NotEmpty() // should be better Require ?
validator.Email()
validator.MinLength(min int)
validator.MaxLength(max int)
Jacalz commented 3 years ago

I might try to give a shot at implementing some of the validators for this, relatively soon.