Skip to content

Commit

Permalink
Consider the known_value field of triggers when relevant
Browse files Browse the repository at this point in the history
The field was wrongly discarded by the validation logic since the latter
expects the interface definition as an additional argument when
validating trigger fields that relate to the interface; when the
interface definition is not provided, the validation defaulted to
discarding the known_value field.
The issue is fixed by not discarding the field in such cases where the
exact field type cannot be retrieved.

Closes #393

Signed-off-by: Davide Briani <davide.briani@secomind.com>
  • Loading branch information
davidebriani committed Jan 22, 2024
1 parent b274ef3 commit 16fd039
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.1.2] - Unreleased
### Fixed
- The known_value filter property for triggers is correctly considered when relevant.
([#393](https://github.com/astarte-platform/astarte-dashboard/issues/393))

## [1.1.1] - 2023-11-15
### Added
Expand Down
5 changes: 4 additions & 1 deletion src/astarte-client/models/Trigger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,12 @@ const astarteSimpleDataTriggerObjectSchema: yup.ObjectSchema<AstarteSimpleDataTr
valueMatchOperator: string | undefined,
iface: AstarteInterface | null,
) => {
if (!iface || !matchPath) {
if (!matchPath) {
return yup.mixed<string | boolean | number>().strip(true);
}
if (!iface) {
return yup.mixed<string | boolean | number>();
}
const matchMapping = iface.mappings.find((m) =>
AstarteMapping.matchEndpoint(m.endpoint, matchPath),
);
Expand Down

0 comments on commit 16fd039

Please sign in to comment.