Skip to content

Commit

Permalink
PropetyModifierToInt: fail for non-strings
Browse files Browse the repository at this point in the history
fixes #2372
  • Loading branch information
Thomas-Gelf committed Aug 12, 2021
1 parent 909fac0 commit f87eff8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/82-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ next (will be 1.9.0)

### Import and Sync
* FIX: string property modifiers now preserve NULL values (#2371)
* FIX: "to int" property modifiers now fails for non-string values (#2372)
* FEATURE: introduce 'disable' as your purge action on Sync (#2285)
* FEATURE: there is now a simple "group by" Property Modifier (#2317)

Expand Down
3 changes: 3 additions & 0 deletions library/Director/PropertyModifier/PropertyModifierToInt.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Icinga\Module\Director\PropertyModifier;

use Icinga\Module\Director\Data\InvalidDataException;
use Icinga\Module\Director\Hook\PropertyModifierHook;

class PropertyModifierToInt extends PropertyModifierHook
Expand All @@ -24,5 +25,7 @@ public function transform($value)
if (is_string($value)) {
return (int) $value;
}

throw new InvalidDataException('String, integer or null', $value);
}
}

0 comments on commit f87eff8

Please sign in to comment.