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: 1840 validator accepts replacement character in stop name field #1870

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ reporting {
}
}

tasks.named('verifyGoogleJavaFormat') {
dependsOn tasks.named('copyRulesToWebClient')
}

task copyRulesToWebClient (type: Copy) {
from "./RULES.md"
into "./web/client/static"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.mobilitydata.gtfsvalidator.notice;

import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.WARNING;

import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.UrlRef;

/**
* This field contains invalid characters such as the replacement character (\uFFFD).
*
* <p>Fields with customer-facing text should not contain invalid characters to ensure good
* readability and accessibility.
*
* <table style="table-layout:auto; width:auto;">
* <caption>Examples:</caption>
* <tr>
* <th><code>Field Text</code></th>
* <th><code>Dataset</code></th>
* </tr>
* <tr>
* <td>"Invalid�Character"</td>
* <td><a href="http://example.com">Example Dataset</a></td>
* </tr>
* </table>
*/
@GtfsValidationNotice(
severity = WARNING,
urls = {
@UrlRef(
label = "Best Practices for All Files",
url = "https://gtfs.org/schedule/reference/#file-requirements")
})
public class InvalidCharactersNotice extends ValidationNotice {

/** Name of the faulty file. */
private final String filename;

/** Name of the faulty field. */
private final String fieldName;

/** Faulty value. */
private final String fieldValue;

/** The row number of the faulty record. */
private final int csvRowNumber;

public InvalidCharactersNotice(
String filename, String fieldName, String fieldValue, int csvRowNumber) {
this.filename = filename;
this.fieldName = fieldName;
this.fieldValue = fieldValue;
this.csvRowNumber = csvRowNumber;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public interface GtfsAgencySchema extends GtfsEntity {

@Required
@MixedCase
@NoInvalidCharacters
String agencyName();

@FieldType(FieldTypeEnum.URL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@

package org.mobilitydata.gtfsvalidator.table;

import org.mobilitydata.gtfsvalidator.annotation.FieldType;
import org.mobilitydata.gtfsvalidator.annotation.FieldTypeEnum;
import org.mobilitydata.gtfsvalidator.annotation.GtfsTable;
import org.mobilitydata.gtfsvalidator.annotation.PrimaryKey;
import org.mobilitydata.gtfsvalidator.annotation.Required;
import org.mobilitydata.gtfsvalidator.annotation.*;

@GtfsTable(
value = "areas.txt",
Expand All @@ -35,5 +31,6 @@ public interface GtfsAreaSchema extends GtfsEntity {
@PrimaryKey
String areaId();

@NoInvalidCharacters
String areaName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@

package org.mobilitydata.gtfsvalidator.table;

import org.mobilitydata.gtfsvalidator.annotation.FieldType;
import org.mobilitydata.gtfsvalidator.annotation.FieldTypeEnum;
import org.mobilitydata.gtfsvalidator.annotation.ForeignKey;
import org.mobilitydata.gtfsvalidator.annotation.GtfsTable;
import org.mobilitydata.gtfsvalidator.annotation.PrimaryKey;
import org.mobilitydata.gtfsvalidator.annotation.Required;
import org.mobilitydata.gtfsvalidator.annotation.*;

@GtfsTable("attributions.txt")
public interface GtfsAttributionSchema extends GtfsEntity {
Expand All @@ -42,6 +37,7 @@ public interface GtfsAttributionSchema extends GtfsEntity {
String tripId();

@Required
@NoInvalidCharacters
String organizationName();

GtfsAttributionRole isProducer();
Expand All @@ -51,11 +47,14 @@ public interface GtfsAttributionSchema extends GtfsEntity {
GtfsAttributionRole isAuthority();

@FieldType(FieldTypeEnum.URL)
@NoInvalidCharacters
String attributionUrl();

@FieldType(FieldTypeEnum.EMAIL)
@NoInvalidCharacters
String attributionEmail();

@FieldType(FieldTypeEnum.PHONE_NUMBER)
@NoInvalidCharacters
String attributionPhone();
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package org.mobilitydata.gtfsvalidator.table;

import org.mobilitydata.gtfsvalidator.annotation.ConditionallyRequired;
import org.mobilitydata.gtfsvalidator.annotation.FieldType;
import org.mobilitydata.gtfsvalidator.annotation.FieldTypeEnum;
import org.mobilitydata.gtfsvalidator.annotation.GtfsTable;
import org.mobilitydata.gtfsvalidator.annotation.MixedCase;
import org.mobilitydata.gtfsvalidator.annotation.PrimaryKey;
import org.mobilitydata.gtfsvalidator.annotation.Required;
import org.mobilitydata.gtfsvalidator.annotation.*;
import org.mobilitydata.gtfsvalidator.type.GtfsTime;

@GtfsTable("booking_rules.txt")
Expand Down Expand Up @@ -41,20 +35,26 @@ public interface GtfsBookingRulesSchema extends GtfsEntity {
String priorNoticeServiceId();

@MixedCase
@NoInvalidCharacters
String message();

@MixedCase
@NoInvalidCharacters
String pickupMessage();

@MixedCase
@NoInvalidCharacters
String dropOffMessage();

@FieldType(FieldTypeEnum.PHONE_NUMBER)
@NoInvalidCharacters
String phoneNumber();

@FieldType(FieldTypeEnum.URL)
@NoInvalidCharacters
String infoUrl();

@FieldType(FieldTypeEnum.URL)
@NoInvalidCharacters
String bookingUrl();
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package org.mobilitydata.gtfsvalidator.table;

import org.mobilitydata.gtfsvalidator.annotation.FieldType;
import org.mobilitydata.gtfsvalidator.annotation.FieldTypeEnum;
import org.mobilitydata.gtfsvalidator.annotation.GtfsTable;
import org.mobilitydata.gtfsvalidator.annotation.PrimaryKey;
import org.mobilitydata.gtfsvalidator.annotation.Required;
import org.mobilitydata.gtfsvalidator.annotation.*;

@GtfsTable("fare_media.txt")
public interface GtfsFareMediaSchema extends GtfsEntity {
Expand All @@ -13,6 +9,7 @@ public interface GtfsFareMediaSchema extends GtfsEntity {
@Required
String fareMediaId();

@NoInvalidCharacters
String fareMediaName();

@Required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,7 @@

import java.math.BigDecimal;
import java.util.Currency;
import org.mobilitydata.gtfsvalidator.annotation.CurrencyAmount;
import org.mobilitydata.gtfsvalidator.annotation.FieldType;
import org.mobilitydata.gtfsvalidator.annotation.FieldTypeEnum;
import org.mobilitydata.gtfsvalidator.annotation.ForeignKey;
import org.mobilitydata.gtfsvalidator.annotation.GtfsTable;
import org.mobilitydata.gtfsvalidator.annotation.Index;
import org.mobilitydata.gtfsvalidator.annotation.NonNegative;
import org.mobilitydata.gtfsvalidator.annotation.PrimaryKey;
import org.mobilitydata.gtfsvalidator.annotation.Required;
import org.mobilitydata.gtfsvalidator.annotation.*;

@GtfsTable("fare_products.txt")
public interface GtfsFareProductSchema extends GtfsEntity {
Expand All @@ -38,6 +30,7 @@ public interface GtfsFareProductSchema extends GtfsEntity {
@Index
String fareProductId();

@NoInvalidCharacters
String fareProductName();

@Required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
@ConditionallyRequired
public interface GtfsFeedInfoSchema extends GtfsEntity {
@Required
@NoInvalidCharacters
String feedPublisherName();

@Required
@FieldType(FieldTypeEnum.URL)
@NoInvalidCharacters
String feedPublisherUrl();

@Required
Expand All @@ -43,11 +45,14 @@ public interface GtfsFeedInfoSchema extends GtfsEntity {
GtfsDate feedEndDate();

@Recommended
@NoInvalidCharacters
String feedVersion();

@FieldType(FieldTypeEnum.EMAIL)
@NoInvalidCharacters
String feedContactEmail();

@FieldType(FieldTypeEnum.URL)
@NoInvalidCharacters
String feedContactUrl();
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ public interface GtfsLevelSchema extends GtfsEntity {
double levelIndex();

@MixedCase
@NoInvalidCharacters
String levelName();
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package org.mobilitydata.gtfsvalidator.table;

import org.mobilitydata.gtfsvalidator.annotation.FieldType;
import org.mobilitydata.gtfsvalidator.annotation.FieldTypeEnum;
import org.mobilitydata.gtfsvalidator.annotation.GtfsTable;
import org.mobilitydata.gtfsvalidator.annotation.MixedCase;
import org.mobilitydata.gtfsvalidator.annotation.PrimaryKey;
import org.mobilitydata.gtfsvalidator.annotation.Required;
import org.mobilitydata.gtfsvalidator.annotation.*;

@GtfsTable("location_groups.txt")
public interface GtfsLocationGroupsSchema extends GtfsEntity {
Expand All @@ -15,5 +10,6 @@ public interface GtfsLocationGroupsSchema extends GtfsEntity {
String locationGroupId();

@MixedCase
@NoInvalidCharacters
String locationGroupName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public interface GtfsNetworkSchema extends GtfsEntity {
String networkId();

@MixedCase
@NoInvalidCharacters
String networkName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ public interface GtfsPathwaySchema extends GtfsEntity {
double minWidth();

@MixedCase
@NoInvalidCharacters
String signpostedAs();

@MixedCase
@NoInvalidCharacters
String reversedSignpostedAs();
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,24 @@ public interface GtfsRouteSchema extends GtfsEntity {

@MixedCase
@ConditionallyRequired
@NoInvalidCharacters
String routeShortName();

@MixedCase
@ConditionallyRequired
@NoInvalidCharacters
String routeLongName();

@MixedCase
@NoInvalidCharacters
String routeDesc();

@Required
@Index
GtfsRouteType routeType();

@FieldType(FieldTypeEnum.URL)
@NoInvalidCharacters
String routeUrl();

@DefaultValue("FFFFFF")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ public interface GtfsStopSchema extends GtfsEntity {
@Required
String stopId();

@NoInvalidCharacters
String stopCode();

@MixedCase
@ConditionallyRequired
@NoInvalidCharacters
String stopName();

@NoInvalidCharacters
String ttsStopName();

@NoInvalidCharacters
String stopDesc();

@FieldType(FieldTypeEnum.LATITUDE)
Expand All @@ -51,6 +55,7 @@ public interface GtfsStopSchema extends GtfsEntity {
String zoneId();

@FieldType(FieldTypeEnum.URL)
@NoInvalidCharacters
String stopUrl();

GtfsLocationType locationType();
Expand All @@ -59,6 +64,7 @@ public interface GtfsStopSchema extends GtfsEntity {
@Index
@ConditionallyRequired
@ForeignKey(table = "stops.txt", field = "stop_id")
@NoInvalidCharacters
String parentStation();

@FieldType(FieldTypeEnum.TIMEZONE)
Expand All @@ -70,5 +76,6 @@ public interface GtfsStopSchema extends GtfsEntity {
@ForeignKey(table = "levels.txt", field = "level_id")
String levelId();

@NoInvalidCharacters
String platformCode();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,7 @@

import static org.mobilitydata.gtfsvalidator.annotation.TranslationRecordIdType.RECORD_SUB_ID;

import org.mobilitydata.gtfsvalidator.annotation.CachedField;
import org.mobilitydata.gtfsvalidator.annotation.ConditionallyRequired;
import org.mobilitydata.gtfsvalidator.annotation.DefaultValue;
import org.mobilitydata.gtfsvalidator.annotation.EndRange;
import org.mobilitydata.gtfsvalidator.annotation.FieldType;
import org.mobilitydata.gtfsvalidator.annotation.FieldTypeEnum;
import org.mobilitydata.gtfsvalidator.annotation.ForeignKey;
import org.mobilitydata.gtfsvalidator.annotation.GtfsTable;
import org.mobilitydata.gtfsvalidator.annotation.Index;
import org.mobilitydata.gtfsvalidator.annotation.NonNegative;
import org.mobilitydata.gtfsvalidator.annotation.PrimaryKey;
import org.mobilitydata.gtfsvalidator.annotation.Required;
import org.mobilitydata.gtfsvalidator.annotation.*;
import org.mobilitydata.gtfsvalidator.type.GtfsTime;

@GtfsTable("stop_times.txt")
Expand Down Expand Up @@ -70,6 +59,7 @@ public interface GtfsStopTimeSchema extends GtfsEntity {
int stopSequence();

@CachedField
@NoInvalidCharacters
String stopHeadsign();

GtfsTime startPickupDropOffWindow();
Expand Down
Loading
Loading