Skip to content

Commit 58b7aff

Browse files
committed
Add nonEmptyStringProperty
1 parent 479e61c commit 58b7aff

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

lib/entry-points.js

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/feature-flags/properties.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ const stringProperty = {
7979
parse: parseStringRepositoryProperty,
8080
};
8181

82+
/** Determines whether a value from the API is a non-empty string or not. */
83+
function isNonEmptyString(value: RepositoryPropertyValue): value is string {
84+
return isString(value) && value.trim().length > 0;
85+
}
86+
87+
/** A repository property that we expect to contain a non-empty string value. */
88+
const nonEmptyStringProperty = {
89+
...stringProperty,
90+
validate: isNonEmptyString,
91+
};
92+
8293
/** A repository property that we expect to contain a boolean value. */
8394
const booleanProperty = {
8495
// The value from the API should come as a string, which we then parse into a boolean.
@@ -90,7 +101,7 @@ const booleanProperty = {
90101
const repositoryPropertyParsers: {
91102
[K in RepositoryPropertyName]: PropertyInfo<K>;
92103
} = {
93-
[RepositoryPropertyName.CONFIG_FILE]: stringProperty,
104+
[RepositoryPropertyName.CONFIG_FILE]: nonEmptyStringProperty,
94105
[RepositoryPropertyName.DISABLE_OVERLAY]: booleanProperty,
95106
[RepositoryPropertyName.EXTRA_QUERIES]: stringProperty,
96107
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: booleanProperty,

0 commit comments

Comments
 (0)