Skip to content

Commit

Permalink
Merge branch 'release/1.0.2' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed May 14, 2018
2 parents 1129e2f + e6ac982 commit 847c7e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Units Changelog

## 1.0.2 - 2018-05-14
### Changed
- Handle cases where there is no `min` or `max` properly in the validator

## 1.0.1 - 2018-05-14
### Changed
- Added null checks in the Field's `init()` method
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-units",
"description": "Units is a plugin that can convert between any units of measure, and comes with a Field for content authors to use",
"type": "craft-plugin",
"version": "1.0.1",
"version": "1.0.2",
"keywords": [
"craft",
"cms",
Expand Down
20 changes: 14 additions & 6 deletions src/validators/EmbeddedUnitsDataValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,20 @@ protected function normalizeMinMax(UnitsData $unitsData)
'units' => $this->units
];
// Normalize the min
$config['value'] = $this->min;
$baseUnit = new UnitsData($config);
$this->min = $baseUnit->toUnit($unitsData->units);
if (!empty($this->min)) {
$config['value'] = (float)$this->min;
$baseUnit = new UnitsData($config);
$this->min = $baseUnit->toUnit($unitsData->units);
} else {
$this->min = null;
}
// Normalize the max
$config['value'] = $this->max;
$baseUnit = new UnitsData($config);
$this->max = $baseUnit->toUnit($unitsData->units);
if (!empty($this->max)) {
$config['value'] = (float)$this->max;
$baseUnit = new UnitsData($config);
$this->max = $baseUnit->toUnit($unitsData->units);
} else {
$this->max = null;
}
}
}

0 comments on commit 847c7e2

Please sign in to comment.