Skip to content

Commit

Permalink
Make most metadata options common for most requests
Browse files Browse the repository at this point in the history
  • Loading branch information
krasun committed Nov 27, 2024
1 parent 521d734 commit dcb6168
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "screenshotone-validations",
"homepage": "https://screenshotone.com",
"version": "1.0.56",
"version": "1.0.57",
"description": "Validation schemes for the ScreenshotOne API requests.",
"repository": {
"type": "git",
Expand Down
34 changes: 18 additions & 16 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,6 @@ const screenshotScheme = {
.default("jpg"),

metadata_image_size: Joi.boolean().default(false),
metadata_fonts: Joi.boolean().default(false),
metadata_content: Joi.boolean().default(false),
metadata_page_title: Joi.boolean().default(false),
metadata_open_graph: Joi.boolean().default(false),
metadata_http_response_status_code: Joi.boolean()
.default(false)
.when("url", {
is: Joi.exist(),
then: Joi.boolean(),
otherwise: Joi.forbidden(),
}),
metadata_http_response_headers: Joi.boolean().default(false).when("url", {
is: Joi.exist(),
then: Joi.boolean(),
otherwise: Joi.forbidden(),
}),

clip_x: Joi.number().integer().optional(),
clip_y: Joi.number().integer().optional(),
Expand Down Expand Up @@ -441,6 +425,24 @@ const commonOptionsScheme = Joi.object({
storage_return_location: Joi.boolean().default(false),

ignore_host_errors: Joi.boolean().default(false),

metadata_fonts: Joi.boolean().default(false),
metadata_content: Joi.boolean().default(false),
metadata_page_title: Joi.boolean().default(false),
metadata_open_graph: Joi.boolean().default(false),
metadata_http_response_status_code: Joi.boolean()
.default(false)
.when("url", {
is: Joi.exist(),
then: Joi.boolean(),
otherwise: Joi.forbidden(),
}),
metadata_http_response_headers: Joi.boolean().default(false).when("url", {
is: Joi.exist(),
then: Joi.boolean(),
otherwise: Joi.forbidden(),
}),

}).oxor("ip_country_code", "proxy");

const optionsScheme = commonOptionsScheme.append(screenshotScheme);
Expand Down

0 comments on commit dcb6168

Please sign in to comment.