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

Some fields do not require validation #86

Open
andrefedev opened this issue Mar 16, 2023 · 2 comments
Open

Some fields do not require validation #86

andrefedev opened this issue Mar 16, 2023 · 2 comments

Comments

@andrefedev
Copy link

Every time a FormZInput is defined we must add a validation error even if we never get to use it. Some fields do not require validation, but do require being inside the form to later verify if the field has changed its value.

Example:

// abstract class FormzInput<T, E>

enum StatusMemberInputError { none }

class StatusMemberInput extends FormzInput<bool, StatusMemberInputError> {
  const StatusMemberInput.pure({bool value = false}) : super.pure(value);

  const StatusMemberInput.dirty({bool value = false}) : super.dirty(value);

  @override
  StatusMemberInputError? validator(bool value) => null;
}
@adityandar
Copy link

have similar use case, currently using your example, but I don't think it's the good way because we still create the error enum.

@codakkk
Copy link

codakkk commented Oct 7, 2023

I wrote a wrapper for this case:

class UnirequiredInput<T> extends FormzInput<T?, void> {
  const UnirequiredInput.pure() : super.pure(null);
  const UnirequiredInput.dirty({T? value}) : super.dirty(value);

  @override
  void validator(T? value) {}
}

But this is just a workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Triage
Development

No branches or pull requests

3 participants