feat(supported-version): validate custom_versions

Previously, @danslo reported that he tried to use `custom_versions` without
setting the kind. This isn't the correct behavior.
I've added a validator to alert him of this.
This commit is contained in:
Damien Retzinger
2023-04-16 15:13:48 -04:00
parent 81a1eb2273
commit 5c198049f7
10 changed files with 69 additions and 42 deletions
@@ -0,0 +1,8 @@
import { KindValidator } from "../validator";
export const customVersionsValidator: KindValidator = (kind, customVersions) => {
if(customVersions && kind !== 'custom') {
throw new Error('`custom_versions` can only be used with kind `custom`');
}
return true;
}
@@ -0,0 +1,11 @@
import { KNOWN_KINDS, Kind } from "../kinds";
export const isKnownKind = (kind: Kind): boolean => {
if(!(kind in KNOWN_KINDS)) {
throw new Error(
`Invalid kind provided, supported kinds are: ${Object.keys(KNOWN_KINDS).join(', ')}`
);
}
return true;
};