chore(catalog-model): use isNonEmptyString for icon validation
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
This commit is contained in:
@@ -197,7 +197,7 @@ describe('FieldFormatEntityPolicy', () => {
|
||||
},
|
||||
);
|
||||
|
||||
it.each([[123], [{}], [[]], ['abc xyz']])(
|
||||
it.each([[123], [{}], [[]]])(
|
||||
'rejects bad link icon value %s',
|
||||
async (icon: unknown) => {
|
||||
data.metadata.links = [{ url: 'http://foo', icon }];
|
||||
@@ -208,10 +208,8 @@ describe('FieldFormatEntityPolicy', () => {
|
||||
it('rejects a single bad link icon value', async () => {
|
||||
data.metadata.links = [
|
||||
{ url: 'http://foo', icon: 'good' },
|
||||
{ url: 'http://foo', icon: 'not good' },
|
||||
{ url: 'http://foo', icon: 123 },
|
||||
];
|
||||
await expect(policy.enforce(data)).rejects.toThrow(
|
||||
/links.1.icon.*"not good"/i,
|
||||
);
|
||||
await expect(policy.enforce(data)).rejects.toThrow(/links.1.icon.*"123"/i);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -161,7 +161,7 @@ export class FieldFormatEntityPolicy implements EntityPolicy {
|
||||
optional(
|
||||
`links.${i}.icon`,
|
||||
links[i]?.icon,
|
||||
KubernetesValidatorFunctions.isValidObjectName,
|
||||
CommonValidatorFunctions.isNonEmptyString,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user