Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b299745
feat(gtfs.yml and validation.js): Updated GTFS Spec for stops.txt and…
May 6, 2021
976b5c7
style(validation.js): removed space
May 6, 2021
b1341cf
refactor(validation.js): SOrted typing issues and removed some code
May 10, 2021
8a9c383
improvement(gtfs.yml, end-to-end.js, index.js,validation.js): WIP: Va…
May 11, 2021
baaba8b
improvement(gtfs.yml): Added continuous_pickup and drop off fields to…
May 11, 2021
acd651a
feat(gtfs.yml): Added fields to feed_info.txt
May 11, 2021
93b1f53
improvement(OatternStopCard.js lib/gtfs/util/index.js lib/types/index…
Jun 1, 2021
5397f4a
refactor(patternStopCard.js): Refactored code from github feedback
Jun 1, 2021
ad6bfe6
refactor(end-to-end.js map.js index.js): Fix errors
Jun 2, 2021
6a9e2ed
refactor(PatternStopCard.js): Refactored based on PR Feedback.
Jun 7, 2021
b30a941
refactor(PatternStopCard.js): REfactor
Jun 8, 2021
c4cf115
refactor(PatternStopCard.js): Refactored drop down select method
Jun 9, 2021
36a759d
refactor(PatternStopCard.js): Fix lint errors
Jun 9, 2021
79073f7
refactor(PatternStopCard.js validation.js): Refactor the form control…
Jun 28, 2021
094efc7
refactor(validation.js PatternStopCard.js): Fix flow issues
Jun 28, 2021
7717c28
fix(PatternStopCard.js): Fix flow issue
Jun 28, 2021
f1cb21e
refactor(validation.js): add validationIssue method
landonreed Jul 1, 2021
ff05ac7
refactor(validation): fix stop name message
landonreed Jul 1, 2021
5d17fbb
refactor(validation): fix bad invocation of validationIssue
landonreed Jul 1, 2021
c728b3d
Merge pull request #690 from ibi-group/gtfs-spec-changes-ltr
Jul 2, 2021
212cf37
refactor(PatternStopCard.js): Changed a method name and added a delet…
Jul 2, 2021
3b97719
refactor(PatternStopCard.js): Changed method name
Jul 2, 2021
826088d
Merge branch 'gtfs-spec-changes' of https://github.com/ibi-group/data…
Jul 2, 2021
4039af7
fix(PatternSTopCard.js): Fixed prop bug
Jul 2, 2021
0255029
fix(PatternStopCard.js): Attempt to fix flow error
Jul 3, 2021
ae5eaae
fix(PatternStopCard.js): Attempt to fix flow issue again
Jul 3, 2021
cb588be
fix(PatternStopCard.js): Attempt to fox flow issue 3
Jul 3, 2021
a95a02c
refactor(PatternStopCard): Separate props for <PickupDropoffSelect>
binh-dam-ibigroup Jul 6, 2021
5696ff1
refactor(editor/util/validation): Add emptyFieldValidationIssue.
binh-dam-ibigroup Jul 6, 2021
2eda50c
Merge pull request #691 from ibi-group/gtfs-spec-changes-qbd
Jul 7, 2021
e692199
refactor(PatternStopCard.js validation.js): Refactor
Jul 7, 2021
f567077
refactor(validation): reuse validation method for 'empty' method
landonreed Jul 7, 2021
589b6c6
fix(validation.js): Remove ES lint waiver
Jul 7, 2021
ef69da3
fix(editor/util/validation): Fix stop name validation.
binh-dam-ibigroup Jul 19, 2021
00ea4d4
style(editor/util/validation): Reformat stop_name validation condition
binh-dam-ibigroup Jul 20, 2021
e180c43
Merge branch 'dev' into gtfs-spec-changes
landonreed Sep 2, 2021
1c5fd78
Merge branch 'dev' into gtfs-spec-changes
binh-dam-ibigroup Sep 16, 2021
59d429a
refactor(PatternStopCard): Clone before updating pickup/dropoff stop …
binh-dam-ibigroup Sep 21, 2021
548fb24
fix(saveEntity, saveTripsForCalendar): Resolve missing defaults with …
philip-cline Sep 22, 2021
c48bb18
refactor(fetchBaseGtfs, saveTripsForCalendar): Fix fetch of new spec …
philip-cline Sep 22, 2021
cda4f65
refactor(saveTripsForCalendar): Fix missing tripCopy ref
philip-cline Sep 22, 2021
be6b088
Merge pull request #720 from ibi-group/resolve-missing-defaults
miles-grant-ibigroup Sep 23, 2021
a5f9c88
Merge branch 'dev' into gtfs-spec-changes
miles-grant-ibigroup Sep 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions gtfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@
columnWidth: 12
helpContent: "The stop_desc field contains a description of a stop. Please provide useful, quality information. Do not simply duplicate the name of the stop."
- name: "stop_lat"
required: true
required: false
inputType: LATITUDE
columnWidth: 6
helpContent: "The stop_lat field contains the latitude of a stop or station. The field value must be a valid WGS 84 latitude."
- name: "stop_lon"
required: true
required: false
inputType: LONGITUDE
columnWidth: 6
helpContent: "The stop_lon field contains the longitude of a stop or station. The field value must be a valid WGS 84 longitude value from -180 to 180."
Expand All @@ -180,6 +180,12 @@
text: Stop (0)
- value: '1'
text: Station (1)
- value: '2'
text: Entrance/Exit (2)
- value: '3'
text: Generic Node (3)
- value: '4'
text: Boarding Area (4)
columnWidth: 12
helpContent: "The location_type field identifies whether this stop ID represents a stop or station. If no location type is specified, or the location_type is blank, stop IDs are treated as stops. Stations may have different properties from stops when they are represented on a map or used in trip planning."
- name: "parent_station"
Expand Down
33 changes: 24 additions & 9 deletions lib/editor/util/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function doesNotExist (value: any): boolean {
* Returns false if the value is ok.
* Returns an EditorValidationIssue object if the value is not ok.
*/
// eslint-disable-next-line complexity
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove that.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not an error-level eslint rule with our eslint config, however, I think there is a lot of value in having it warn the developer because having functions with tons of complexity will make code very difficult to read and maintain in the future. It's not your fault that this method is bloated in the first place, but it will significantly improve the future readability and maintainability of this code to refactor this method into smaller chunks right now.

export function validate (
field: GtfsSpecField,
value: any,
Expand All @@ -36,8 +37,8 @@ export function validate (
const valueDoesNotExist = doesNotExist(value)
const isRequiredButEmpty = required && valueDoesNotExist
const isOptionalAndEmpty = !required && valueDoesNotExist
let reason = 'Required field must not be empty'
const agencies = getTableById(tableData, 'agency')
let reason = 'Required field must not be empty'

// setting as a variable here because of eslint bug
type CheckPositiveOutput = {
Expand Down Expand Up @@ -100,6 +101,12 @@ export function validate (
(indices.length > 1 ||
(indices.length > 0 && entities[indices[0]].id !== entity.id))
)
console.log(idList.length)
console.log({entity})
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove console statements.

if (agencies.length > 1 && entity.agency_id === null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Try using valueDoesNotExist, isOptionalAndEmpty defined for the function that already checked for null/undefined/empty string.

Copy link
Author

Choose a reason for hiding this comment

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

Good point!

reason = 'Identifier is required if more than one agency exists'
return {field: name, invalid: isRequiredButEmpty, reason}
}
if (isRequiredButEmpty || isNotUnique) {
if (isNotUnique) {
reason = 'Identifier must be unique'
Expand Down Expand Up @@ -175,21 +182,29 @@ export function validate (
}
case 'LATITUDE':
const isNotLat = value > 90 || value < -90
if (isRequiredButEmpty || isNotLat) {
if (isNotLat) {
reason = 'Field must be valid latitude.'
if (isNotLat) {
reason = 'Field must be valid latitude.'
return {field: name, invalid: isOptionalAndEmpty || isNotLat, reason}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the range check from isNotLat be enforced here regardless of stop type?

Copy link
Author

Choose a reason for hiding this comment

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

@binh-dam-ibigroup it is being enforced regardless. Line 189 is the conditional for the location_type:

image

if (entity && entity.location_type >= 2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

<= 2 rather?

Copy link
Author

Choose a reason for hiding this comment

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

Yes! 🤦‍♂️

if (isOptionalAndEmpty) {
reason = '1 Latitude and Longitude are required for your current location type'
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove leading 1

return {field: name, invalid: isOptionalAndEmpty || isNotLat, reason}
}
return {field: name, invalid: isRequiredButEmpty || isNotLat, reason}
} else {
return false
}
case 'LONGITUDE':
const isNotLng = value > 180 || value < -180
if (isRequiredButEmpty || isNotLng) {
if (isNotLng) {
reason = 'Field must be valid longitude.'
if (isNotLng) {
reason = 'Field must be valid longitude.'
return {field: name, invalid: isOptionalAndEmpty || isNotLng, reason}
}
if (entity && entity.location_type >= 2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

<= 2 instead?

Copy link
Author

Choose a reason for hiding this comment

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

Yes! 🤦‍♂️

if (isOptionalAndEmpty) {
reason = '1 Latitude and Longitude are required for your current location type'
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove leading 1

return {field: name, invalid: isOptionalAndEmpty || isNotLng, reason}
}
return {field: name, invalid: isRequiredButEmpty || isNotLng, reason}
} else {
return false
}
Expand Down