mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Fleet] fix validate package policy error (#208528)
## Summary Closes https://github.com/elastic/kibana/issues/208519 To verify: - Add Network Packet Capture integration - verify that there is no UI error when adding the package policy <img width="1418" alt="image" src="https://github.com/user-attachments/assets/2806f717-995a-4c7a-9532-08be30f0cd10" /> ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
parent
5672d8815a
commit
512bce0b87
2 changed files with 21 additions and 1 deletions
|
@ -1243,6 +1243,25 @@ describe('Fleet - validatePackagePolicyConfig', () => {
|
|||
|
||||
expect(res).toEqual(['myvariable is required']);
|
||||
});
|
||||
|
||||
it('should accept integer', () => {
|
||||
const res = validatePackagePolicyConfig(
|
||||
{
|
||||
type: 'text',
|
||||
value: [1],
|
||||
},
|
||||
{
|
||||
name: 'myvariable',
|
||||
type: 'text',
|
||||
multi: true,
|
||||
required: true,
|
||||
},
|
||||
'myvariable',
|
||||
load
|
||||
);
|
||||
|
||||
expect(res).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Integer', () => {
|
||||
|
|
|
@ -370,7 +370,8 @@ export const validatePackagePolicyConfig = (
|
|||
}
|
||||
if (varDef.required && Array.isArray(parsedValue)) {
|
||||
const hasEmptyString =
|
||||
varDef.type === 'text' && parsedValue.some((item) => item.trim() === '');
|
||||
varDef.type === 'text' &&
|
||||
parsedValue.some((item) => typeof item === 'string' && item.trim() === '');
|
||||
|
||||
if (hasEmptyString || parsedValue.length === 0) {
|
||||
errors.push(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue