Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix validation

Krzysztof Świątekec95fdd67774
diff --git a/saleor/graphql/product/bulk_mutations/products.py b/saleor/graphql/product/bulk_mutations/products.py
index 36f60a84a4..df5037253e 100644
--- a/saleor/graphql/product/bulk_mutations/products.py
+++ b/saleor/graphql/product/bulk_mutations/products.py
@@ -159,7 +159,7 @@ class ProductVariantBulkCreate(BaseMutation):
raise ValidationError(
{
"basePrice": ValidationError(
- ("Product price cannot be lower than 0."),
+ "Product price cannot be lower than 0.",
code=ProductErrorCode.INVALID,
)
}
@@ -172,7 +172,7 @@ class ProductVariantBulkCreate(BaseMutation):
raise ValidationError(
{
"basePrice": ValidationError(
- ("Product price cannot be lower than 0."),
+ "Product price cannot be lower than 0.",
code=ProductErrorCode.INVALID,
)
}
diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.py
index f05693bbac..b296f6ad6c 100644
--- a/saleor/graphql/product/mutations/products.py
+++ b/saleor/graphql/product/mutations/products.py
@@ -837,7 +837,7 @@ class ProductCreate(ModelMutation):
raise ValidationError(
{
"basePrice": ValidationError(
- ("Product base price cannot be lower than 0."),
+ "Product base price cannot be lower than 0.",
code=ProductErrorCode.INVALID,
)
}
@@ -1185,11 +1185,11 @@ class ProductVariantCreate(ModelMutation):
if "cost_price" in cleaned_input:
cost_price = cleaned_input.pop("cost_price")
- if cost_price < 0:
+ if cost_price and cost_price < 0:
raise ValidationError(
{
"costPrice": ValidationError(
- ("Product price cannot be lower than 0."),
+ "Product price cannot be lower than 0.",
code=ProductErrorCode.INVALID,
)
}
@@ -1198,11 +1198,11 @@ class ProductVariantCreate(ModelMutation):
if "price_override" in cleaned_input:
price_override = cleaned_input.pop("price_override")
- if price_override < 0:
+ if price_override and price_override < 0:
raise ValidationError(
{
"priceOverride": ValidationError(
- ("Product price cannot be lower than 0."),
+ "Product price cannot be lower than 0.",
code=ProductErrorCode.INVALID,
)
}