formz
formz copied to clipboard
Performance-friendly validation
Use case
Currently FormzInput.isValid
/ FormzInput.isNotValid
/ FormzInput.error
/ FormzInput.displayError
/ FormzInput.validator
/ Formz .validate
methods / getters always recalculate the error
which is waste of cpu cycle.
FormzInput
is @immutable
abstract class and it's validator
method should return same result no matter how many times called at any point in time (pure function) since the validation logic can be expensive for instance a long regexp.
Proposal
- Error should be calculated at construct time
- Error should be lazy calaculated