Skip to content

Commit

Permalink
update schema to enforce dropdown validation for PATH field
Browse files Browse the repository at this point in the history
  • Loading branch information
ashokaditya committed Apr 21, 2021
1 parent 8c19290 commit 1deab39
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ export const GetTrustedAppsRequestSchema = {
};

const ConditionEntryTypeSchema = schema.literal('match');
const ConditionEntryOperatorSchema = schema.oneOf([
schema.literal(OperatorEntryField.included),
schema.literal(OperatorEntryField.wildcard_caseless),
]);
// when field === PATH -> operator in ('included', 'wildcard_caseless') else operator === 'included'
const ConditionEntryOperatorSchema = schema.conditional(
schema.siblingRef('field'),
ConditionEntryField.PATH,
schema.oneOf([
schema.literal(OperatorEntryField.included),
schema.literal(OperatorEntryField.wildcard_caseless),
]),
schema.literal(OperatorEntryField.included)
);

/*
* A generic Entry schema to be used for a specific entry schema depending on the OS
Expand Down

0 comments on commit 1deab39

Please sign in to comment.