Skip to content

Commit

Permalink
Fixed script validation
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 23, 2021
1 parent 8ed495a commit 3ca04e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ui/src/app/form/component/fields/FilterTargetField.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ const FilterTargetField = ({
className="codearea form-control"
rows="8"
onChange={({ target: { value } }) => handleTextChange(value)}
html={ selectedTarget[0] }
html={ selectedTarget[0] ? selectedTarget[0] : '' }
innerRef={ref}
dangerouslySetInnerHTML={true}>
</ContentEditable>
<small id="script-help" className="text-danger">
{!selectedTarget[0] && <small id="script-help" className="text-danger">
<Translate value="message.required-for-scripts">Required for Scripts</Translate>
</small>
</small>}
</> }
{targetType === 'REGEX' &&
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ export const EntityAttributesFilterWizard = {
errors.entityAttributesFilterTarget.value.addError('message.invalid-regex-pattern');
}
}

if (formData?.entityAttributesFilterTarget?.entityAttributesFilterTargetType === 'CONDITION_SCRIPT') {
const { entityAttributesFilterTarget: { value } } = formData;
if (!value[0]) {
errors.entityAttributesFilterTarget.value.addError('message.required-for-scripts');
}
}
return errors;
}
},
Expand Down
7 changes: 7 additions & 0 deletions ui/src/app/metadata/domain/filter/NameIdFilterDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ export const NameIDFilterWizard = {
errors.nameIdFormatFilterTarget.value.addError('message.invalid-regex-pattern');
}
}

if (formData?.nameIdFormatFilterTarget?.nameIdFormatFilterTargetType === 'CONDITION_SCRIPT') {
const { nameIdFormatFilterTarget: { value } } = formData;
if (!value[0]) {
errors.nameIdFormatFilterTarget.value.addError('message.required-for-scripts');
}
}
return errors;
}
},
Expand Down

0 comments on commit 3ca04e0

Please sign in to comment.