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

feat: Initial support for Fares v2 validation. #1228

Merged
merged 21 commits into from
Oct 3, 2022

Conversation

bdferris-v2
Copy link
Collaborator

Per issue #1201, adds validation for files and fields added for Fares v2 base spec changes.

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with gradle test to make sure you didn't break anything
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues

@bdferris-v2 bdferris-v2 linked an issue Aug 5, 2022 that may be closed by this pull request
@bdferris-v2
Copy link
Collaborator Author

Initial draft, mostly to see what happens when validating a few existing feeds.


@PrimaryKey(translationRecordIdType = UNSUPPORTED)
@Positive
int durationLimit();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question: if we have a negative integer in this field, will this trigger the invalid_integer notice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm it triggers at number_out_of_range validation error.

@bdferris-v2 bdferris-v2 marked this pull request as ready for review September 14, 2022 22:55
@bdferris-v2
Copy link
Collaborator Author

Now that #1248 has been committed and integrated, this PR is ready for official review.

Copy link
Collaborator

@KClough KClough left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an official reviewer, but lgtm.

Copy link
Contributor

@isabelle-dr isabelle-dr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @bdferris-v2 🔥
Two things:

  1. We are missing documentation for invalid_fare_transfer_rule_transfer_count and fare_transfer_rule_missing_transfer_count.

  2. I would like to include three additional rules in the scope of this PR.

  • missing_fare_rule_file
    • spec mention in Dataset files: fare_rules.txt is required if fare_attributes.txt is defined.
    • pseudo code: if fare_attributes.txt if present and fare_rules.txt is absent, trigger the notice.
  • forbidden_fare_rule_file
    • spec mention in Dataset files: fare_rules.txt is forbidden if fare_attributes.txt is not defined.
    • pseudo code: if fare_attributes.txt if absent and fare_rules.txt is present, trigger the notice.
  • fare_transfer_rule_forbidden_duration_limit
    • spec mention in fare_transfer_rules.duration_limit_type: Forbidden if fare_transfer_rules.duration_limit is empty.
    • pseudo code: If [fare_transfer_rules.duration_limit == '' and fare_transfer_rules.duration_limit_type != ''], trigger the notice

I have a copy of the fares v2 spec changes with my comments in https://bit.ly/faresv2-validator.

@maximearmstrong
Copy link
Contributor

maximearmstrong commented Sep 27, 2022

fare_transfer_rule_forbidden_duration_limit

  • spec mention in fare_transfer_rules.duration_limit_type: Forbidden if fare_transfer_rules.duration_limit is empty.
  • pseudo code: If [fare_transfer_rules.duration_limit == '' and fare_transfer_rules.duration_limit_type != ''], trigger the notice

@isabelle-dr I think this has been already added with the FareTransferRuleDurationLimitWithoutTypeNotice here. Could you confirm this is what you were looking for?

Copy link
Contributor

@maximearmstrong maximearmstrong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I've only one small comment. I think after Isabelle's requested changes are done, we'll be ready to merge. Thanks @bdferris-v2

@bdferris-v2
Copy link
Collaborator Author

I believe @isabelle-dr was correct that I didn't have a validation check for when duration_limit_type was specified but duration_limit was not. I've added that now.

I believe all validation rules have documentation in RULES.md at this point. Let me know if you see things differently.

As for fare_rules.txt and fare_attributes.txt, those seem to be clarifications of the Fares V1 spec. I'm happy to add support for that, but I'd argue for splitting it out into a separate PR to keep things (relatively) focused. Thoughts?

Copy link
Contributor

@isabelle-dr isabelle-dr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Thanks for making this advance 🙏

For the documentation, I believe we are still missing the first rule you have in FareTransferCountValidator.java (line 47). It is invalid_fare_transfer_rule_transfer_count.

As for the two additional rules I mentioned here, I see fare_rules.txt was introduced in Fares v1, but it went from being optional to conditionally required/forbidden in the PR that added GTFS-Fares v2 base implementation on google/transit (reference).
If the scope of this PR is adding validation for the changes introduced in this PR, I would say it's in scope.

@isabelle-dr isabelle-dr added this to the Q4 2022 milestone Oct 3, 2022
Copy link
Contributor

@isabelle-dr isabelle-dr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

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

Successfully merging this pull request may close these issues.

Add rules for the Fares v2 base implementation
4 participants