formz icon indicating copy to clipboard operation
formz copied to clipboard

Performance-friendly validation

Open maRci002 opened this issue 2 years ago • 0 comments

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

maRci002 avatar Jun 09 '22 21:06 maRci002