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