debian-image-builder-frontend/src/Components/CreateImageWizard/validators/targetEnvironmentValidator.js
lucasgarfield 4000b8d5e5 ESLint: Add prefer-const rule
Require const declarations for variables that are never reassigned after
being declared. If a variable is never reassigned, using the const
declaration is better. const declaration tells readers, “this variable
is never reassigned,” reducing cognitive load and improving
maintainability.
2023-02-10 11:37:06 +01:00

17 lines
497 B
JavaScript

const TargetEnvironmentValidator = () => (targets) => {
if (!targets) {
return undefined;
}
// at least one of the target environments must
// be set to true. This reduces the value to
// a single boolean which is a flag for whether
// at least one target has been selected or not
const valid = Object.values(targets).reduce(
(prev, curr) => curr || prev,
false
);
return !valid ? 'Please select an image' : undefined;
};
export default TargetEnvironmentValidator;