verifyOptions() — astro Function Reference
Architecture documentation for the verifyOptions() function in service.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 4cca3d1a_d2b8_5989_f8cd_75455a62f75f["verifyOptions()"] f0f55fc4_9c63_b35c_86d8_8eb3e4fa20ee["service.ts"] 4cca3d1a_d2b8_5989_f8cd_75455a62f75f -->|defined in| f0f55fc4_9c63_b35c_86d8_8eb3e4fa20ee 26530394_92cc_61b1_b120_5db453d098e6["baseService.validateOptions()"] 26530394_92cc_61b1_b120_5db453d098e6 -->|calls| 4cca3d1a_d2b8_5989_f8cd_75455a62f75f style 4cca3d1a_d2b8_5989_f8cd_75455a62f75f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/assets/services/service.ts lines 144–205
export function verifyOptions(options: ImageTransform): void {
// `src` is missing or is `undefined`.
if (!options.src || (!isRemoteImage(options.src) && !isESMImportedImage(options.src))) {
throw new AstroError({
...AstroErrorData.ExpectedImage,
message: AstroErrorData.ExpectedImage.message(
JSON.stringify(options.src),
typeof options.src,
JSON.stringify(options, (_, v) => (v === undefined ? null : v)),
),
});
}
if (!isESMImportedImage(options.src)) {
// User passed an `/@fs/` path or a filesystem path instead of the full image.
if (
options.src.startsWith('/@fs/') ||
(!isRemotePath(options.src) && !options.src.startsWith('/'))
) {
throw new AstroError({
...AstroErrorData.LocalImageUsedWrongly,
message: AstroErrorData.LocalImageUsedWrongly.message(options.src),
});
}
// For remote images, width and height are explicitly required as we can't infer them from the file
let missingDimension: 'width' | 'height' | 'both' | undefined;
if (!options.width && !options.height) {
missingDimension = 'both';
} else if (!options.width && options.height) {
missingDimension = 'width';
} else if (options.width && !options.height) {
missingDimension = 'height';
}
if (missingDimension) {
throw new AstroError({
...AstroErrorData.MissingImageDimension,
message: AstroErrorData.MissingImageDimension.message(missingDimension, options.src),
});
}
} else {
if (!VALID_SUPPORTED_FORMATS.includes(options.src.format as any)) {
throw new AstroError({
...AstroErrorData.UnsupportedImageFormat,
message: AstroErrorData.UnsupportedImageFormat.message(
options.src.format,
options.src.src,
VALID_SUPPORTED_FORMATS,
),
});
}
if (options.widths && options.densities) {
throw new AstroError(AstroErrorData.IncompatibleDescriptorOptions);
}
if (options.src.format !== 'svg' && options.format === 'svg') {
throw new AstroError(AstroErrorData.UnsupportedImageConversion);
}
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does verifyOptions() do?
verifyOptions() is a function in the astro codebase, defined in packages/astro/src/assets/services/service.ts.
Where is verifyOptions() defined?
verifyOptions() is defined in packages/astro/src/assets/services/service.ts at line 144.
What calls verifyOptions()?
verifyOptions() is called by 1 function(s): baseService.validateOptions.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free