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

Validation of 2 fields against each other #30

Closed
herman-the-worm opened this issue Mar 10, 2021 · 3 comments
Closed

Validation of 2 fields against each other #30

herman-the-worm opened this issue Mar 10, 2021 · 3 comments
Assignees

Comments

@herman-the-worm
Copy link

@felangel

This is related to issue #5

I am curious to how it would work out if there are 2 inputs that have to be validated against each other.

This method won't work anymore since 2 objects cannot co-create each other.

@felangel what would be a direction in this case?

The example of would be 2 time entries that need to be verified against each other.

Like start time and end time.

If I add the code example from above the the end_time field then it is only verified against start_time. But start_time is not verified against the initial field and I am struggling to find an elegant solution to solve this.

@ycherniavskyi
Copy link

Hm, what about treating these 2 fields as one complex field (as it seems it is in such case).

class ComplexObject {
  // ...
  final SomeObject one;
  final SomeObject two;
  // ...
}

class ComplexObjectFormzInput extends FormzInput<ComplexObject, FieldValidationError> {
  const ComplexObjectFormzInput() : super.pure(ComplexObject());
  const ComplexObjectFormzInput([ComplexObject value = ComplexObject()]) : super.dirty(value);

  @override
  FieldValidationError validator(ComplexObject value) {
    // ...
  }
}

@herman-the-worm
Copy link
Author

@ycherniavskyi Thank you for the advice. I will try to implement and provide feedback here in the comment.

Thanks for your input

@felangel
Copy link
Contributor

Closing for now but feel free to comment with additional questions and I'm happy to continue the conversation 👍

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

No branches or pull requests

3 participants