Skip to content

Commit fb14e37

Browse files
committed
update validate code
1 parent d90f178 commit fb14e37

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

scripts/validate-partners.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,23 @@ export async function checkImageDimensions(
131131
if (!width || !height) {
132132
errorMessages.push(`Image metadata could not be read for ${filePath}`);
133133
} else {
134-
if (isWidthExact && width !== maxWidth) {
135-
errorMessages.push(`Image width is ${width}px, but expected ${maxWidth}px`);
136-
}
137-
138-
if (isHeightExact && height !== maxHeight) {
139-
errorMessages.push(`Image height is ${height}px, but expected ${maxHeight}px`);
134+
if (isWidthExact) {
135+
if (width !== maxWidth) {
136+
errorMessages.push(`Image width is ${width}px, but expected exactly ${maxWidth}px`);
137+
}
138+
} else {
139+
if (width > maxWidth) {
140+
errorMessages.push(`Image width is ${width}px, which exceeds the maximum allowed ${maxWidth}px`);
141+
}
140142
}
141143

142-
if (!isWidthExact && !isHeightExact) {
143-
if (width > maxWidth || height > maxHeight) {
144-
errorMessages.push(`Image dimensions ${width}x${height}px exceed maximum ${maxWidth}x${maxHeight}px`);
144+
if (isHeightExact) {
145+
if (height !== maxHeight) {
146+
errorMessages.push(`Image height is ${height}px, but expected exactly ${maxHeight}px`);
147+
}
148+
} else {
149+
if (height > maxHeight) {
150+
errorMessages.push(`Image height is ${height}px, which exceeds the maximum allowed ${maxHeight}px`);
145151
}
146152
}
147153
}

0 commit comments

Comments
 (0)