private void validateChange(Sample sample, Sample beforeChange) throws IOException {
List<ValidationError> errors = new ArrayList<>();
validateConcentrationUnits(sample.getConcentration(), sample.getConcentrationUnits(), errors);
validateVolumeUnits(sample.getVolume(), sample.getVolumeUnits(), errors);
validateBarcodeUniqueness(sample, beforeChange, sampleStore::getByBarcode, errors, "sample");
validateDistributionFields(sample.isDistributed(), sample.getDistributionDate(), sample.getDistributionRecipient(), sample.getBox(),
errors);
validateUnboxableFields(sample.isDiscarded(), sample.isDistributed(), sample.getBox(), errors);
if (taxonLookupEnabled && (beforeChange == null || !sample.getScientificName().equals(beforeChange.getScientificName()))
&& (sample.getScientificName() == null || TaxonomyUtils.checkScientificNameAtNCBI(sample.getScientificName()) == null)) {
errors.add(new ValidationError("scientificName", "This scientific name is not of a known taxonomy"));
}
if (!errors.isEmpty()) {
throw new ValidationException(errors);
}
}