fix: product and variant api route validation (#331)
This commit is contained in:
1 parent
cfe19f7f9d
commit
b101725396
4 files changed
+75
-26
No files matched your search
@@ -222,10 +222,18 @@ export default async (req, res) => {
|
|||||||
inventory_quantity: Validator.number().default(0),
|
inventory_quantity: Validator.number().default(0),
|
||||||
allow_backorder: Validator.boolean().optional(),
|
allow_backorder: Validator.boolean().optional(),
|
||||||
manage_inventory: Validator.boolean().optional(),
|
manage_inventory: Validator.boolean().optional(),
|
||||||
weight: Validator.number().optional(),
|
weight: Validator.number()
|
||||||
length: Validator.number().optional(),
|
.allow(null)
|
||||||
height: Validator.number().optional(),
|
.optional(),
|
||||||
width: Validator.number().optional(),
|
length: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
|
height: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
|
width: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
origin_country: Validator.string()
|
origin_country: Validator.string()
|
||||||
.optional()
|
.optional()
|
||||||
.allow("")
|
.allow("")
|
||||||
@@ -259,10 +267,18 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
.default([]),
|
.default([]),
|
||||||
}),
|
}),
|
||||||
weight: Validator.number().optional(),
|
weight: Validator.number()
|
||||||
length: Validator.number().optional(),
|
.allow(null)
|
||||||
height: Validator.number().optional(),
|
.optional(),
|
||||||
width: Validator.number().optional(),
|
length: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
|
height: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
|
width: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
hs_code: Validator.string()
|
hs_code: Validator.string()
|
||||||
.optional()
|
.optional()
|
||||||
.allow(""),
|
.allow(""),
|
||||||
|
|||||||
@@ -115,10 +115,18 @@ export default async (req, res) => {
|
|||||||
inventory_quantity: Validator.number().default(0),
|
inventory_quantity: Validator.number().default(0),
|
||||||
allow_backorder: Validator.boolean().optional(),
|
allow_backorder: Validator.boolean().optional(),
|
||||||
manage_inventory: Validator.boolean().optional(),
|
manage_inventory: Validator.boolean().optional(),
|
||||||
weight: Validator.number().optional(),
|
weight: Validator.number()
|
||||||
length: Validator.number().optional(),
|
.allow(null)
|
||||||
height: Validator.number().optional(),
|
.optional(),
|
||||||
width: Validator.number().optional(),
|
length: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
|
height: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
|
width: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
origin_country: Validator.string().allow(""),
|
origin_country: Validator.string().allow(""),
|
||||||
mid_code: Validator.string().allow(""),
|
mid_code: Validator.string().allow(""),
|
||||||
material: Validator.string().allow(""),
|
material: Validator.string().allow(""),
|
||||||
@@ -127,7 +135,7 @@ export default async (req, res) => {
|
|||||||
.items(
|
.items(
|
||||||
Validator.object()
|
Validator.object()
|
||||||
.keys({
|
.keys({
|
||||||
region_id: Validator.string(),
|
region_id: Validator.string().empty(null),
|
||||||
currency_code: Validator.string().required(),
|
currency_code: Validator.string().required(),
|
||||||
amount: Validator.number()
|
amount: Validator.number()
|
||||||
.integer()
|
.integer()
|
||||||
|
|||||||
@@ -210,11 +210,20 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
handle: Validator.string().optional(),
|
handle: Validator.string().optional(),
|
||||||
weight: Validator.number().optional(),
|
weight: Validator.number()
|
||||||
length: Validator.number().optional(),
|
.allow(null)
|
||||||
height: Validator.number().optional(),
|
.optional(),
|
||||||
width: Validator.number().optional(),
|
length: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
|
height: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
|
width: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
origin_country: Validator.string().allow(null, ""),
|
origin_country: Validator.string().allow(null, ""),
|
||||||
|
hs_code: Validator.string().allow(null, ""),
|
||||||
mid_code: Validator.string().allow(null, ""),
|
mid_code: Validator.string().allow(null, ""),
|
||||||
material: Validator.string().allow(null, ""),
|
material: Validator.string().allow(null, ""),
|
||||||
images: Validator.array()
|
images: Validator.array()
|
||||||
@@ -250,10 +259,18 @@ export default async (req, res) => {
|
|||||||
inventory_quantity: Validator.number().allow(null),
|
inventory_quantity: Validator.number().allow(null),
|
||||||
allow_backorder: Validator.boolean().allow(null),
|
allow_backorder: Validator.boolean().allow(null),
|
||||||
manage_inventory: Validator.boolean().allow(null),
|
manage_inventory: Validator.boolean().allow(null),
|
||||||
weight: Validator.number().optional(),
|
weight: Validator.number()
|
||||||
length: Validator.number().optional(),
|
.allow(null)
|
||||||
height: Validator.number().optional(),
|
.optional(),
|
||||||
width: Validator.number().optional(),
|
length: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
|
height: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
|
width: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
hs_code: Validator.string()
|
hs_code: Validator.string()
|
||||||
.optional()
|
.optional()
|
||||||
.allow(null, ""),
|
.allow(null, ""),
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export default async (req, res) => {
|
|||||||
prices: Validator.array().items(
|
prices: Validator.array().items(
|
||||||
Validator.object()
|
Validator.object()
|
||||||
.keys({
|
.keys({
|
||||||
region_id: Validator.string(),
|
region_id: Validator.string().empty(null),
|
||||||
currency_code: Validator.string(),
|
currency_code: Validator.string(),
|
||||||
amount: Validator.number()
|
amount: Validator.number()
|
||||||
.integer()
|
.integer()
|
||||||
@@ -133,10 +133,18 @@ export default async (req, res) => {
|
|||||||
inventory_quantity: Validator.number().optional(),
|
inventory_quantity: Validator.number().optional(),
|
||||||
allow_backorder: Validator.boolean().optional(),
|
allow_backorder: Validator.boolean().optional(),
|
||||||
manage_inventory: Validator.boolean().optional(),
|
manage_inventory: Validator.boolean().optional(),
|
||||||
weight: Validator.number().optional(),
|
weight: Validator.number()
|
||||||
length: Validator.number().optional(),
|
.allow(null)
|
||||||
height: Validator.number().optional(),
|
.optional(),
|
||||||
width: Validator.number().optional(),
|
length: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
|
height: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
|
width: Validator.number()
|
||||||
|
.allow(null)
|
||||||
|
.optional(),
|
||||||
hs_code: Validator.string()
|
hs_code: Validator.string()
|
||||||
.optional()
|
.optional()
|
||||||
.allow(null, ""),
|
.allow(null, ""),
|
||||||
|
|||||||
Reference in new issue
Block a user