Skip to content
Merged
Changes from 1 commit
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
32 changes: 19 additions & 13 deletions lib/editor/util/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ export function validate (
const isRequiredButEmpty = required && valueDoesNotExist
const isOptionalAndEmpty = !required && valueDoesNotExist
const agencies = getTableById(tableData, 'agency')
let locationType: ?number = 0
let reason = 'Required field must not be empty'

// entity.locationtype is a string. Convert to number for conditinals later on.
if (entity && entity.location_type) {
locationType = parseInt(entity.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.

Always supply the radix argument to parseInt. Learn more here.

}

// setting as a variable here because of eslint bug
type CheckPositiveOutput = {
num?: number,
Expand Down Expand Up @@ -101,9 +107,11 @@ export function validate (
(indices.length > 1 ||
(indices.length > 0 && entities[indices[0]].id !== entity.id))
)
console.log(idList.length)
console.log({entity})
if (agencies.length > 1 && entity.agency_id === null) {
if (
name === 'agency_id' &&
idList.length > 1 &&
valueDoesNotExist
) {
reason = 'Identifier is required if more than one agency exists'
return {field: name, invalid: isRequiredButEmpty, reason}
}
Expand Down Expand Up @@ -184,30 +192,28 @@ export function validate (
const isNotLat = value > 90 || value < -90
if (isNotLat) {
reason = 'Field must be valid latitude.'
return {field: name, invalid: isOptionalAndEmpty || isNotLat, reason}
return {field: name, invalid: isNotLat, reason}
}
if (entity && entity.location_type >= 2) {
if (!locationType || locationType < 2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Check the GTFS reference for the location types, I think the condition should be <= 2: https://developers.google.com/transit/gtfs/reference#stopstxt

if (isOptionalAndEmpty) {
reason = '1 Latitude and Longitude are required for your current location type'
return {field: name, invalid: isOptionalAndEmpty || isNotLat, reason}
reason = 'Latitude and Longitude are required for your current location type'
return {field: name, invalid: isOptionalAndEmpty, reason}
}
} else {
return false
}
return false
case 'LONGITUDE':
const isNotLng = value > 180 || value < -180
if (isNotLng) {
reason = 'Field must be valid longitude.'
return {field: name, invalid: isOptionalAndEmpty || isNotLng, reason}
}
if (entity && entity.location_type >= 2) {
if (!locationType || locationType < 2) {
if (isOptionalAndEmpty) {
reason = '1 Latitude and Longitude are required for your current location type'
reason = 'Latitude and Longitude are required for your current location type'
return {field: name, invalid: isOptionalAndEmpty || isNotLng, reason}
}
} else {
return false
}
return false
case 'TIME':
case 'NUMBER':
const isNotANumber = isNaN(value)
Expand Down