Fix some RegEx io-ts types

io-ts types that were generated using `shortStringWithRegex` were testing
against `VAR_NAME_REGEX`, instead of the Regex that was specified when
generating the type. This affected `DockerName` such that service names with
a dash in the middle were returning as false when passed through the
`DockerName.is` type guard, affecting how `getServicesLockedByAppId` was
returning a map of locked services.

Change-type: patch
Signed-off-by: Christina Ying Wang <christina@balena.io>
This commit is contained in:
Christina Ying Wang 2024-04-06 00:20:34 -07:00
parent aa00727f45
commit b7922e6875

View File

@ -96,7 +96,7 @@ const CONFIG_VAR_NAME_REGEX = /^[a-zA-Z_][a-zA-Z0-9_:]*$/;
const shortStringWithRegex = (name: string, regex: RegExp, message: string) =>
new t.Type<string, string>(
name,
(s: unknown): s is string => ShortString.is(s) && VAR_NAME_REGEX.test(s),
(s: unknown): s is string => ShortString.is(s) && regex.test(s),
(i, c) =>
pipe(
ShortString.validate(i, c),