Skip to content

Commit

Permalink
fix(deps): update dependency yup to v1 (#3061)
Browse files Browse the repository at this point in the history
* fix(deps): update dependency yup to v1

* fix: tests

* fix: some more tests

* fix: all tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Muhammad Anas <muhammad.anas@arbisoft.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 10, 2024
1 parent 6761e91 commit 433b112
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 48 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"webpack-cli": "^4.8.0",
"webpack-dev-middleware": "^5.0.0",
"webpack-hot-middleware": "^2.25.0",
"yup": "^0.31.0"
"yup": "^1.0.0"
},
"engines": {
"node": "20.17.0"
Expand Down
41 changes: 18 additions & 23 deletions static/js/components/forms/CouponForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const couponValidations = yup.object().shape({
coupon_type: yup.string().required("Coupon type is required"),
products: yup.array().when("is_global", {
is: false,
then: yup.array().min(1, "${min} or more products must be selected"),
then: (schema) => schema.min(1, "${min} or more products must be selected"),
}),
is_global: yup.boolean(),
activation_date: yup.date().required("Valid activation date required"),
Expand All @@ -52,50 +52,45 @@ const couponValidations = yup.object().shape({
.min(1, "Must be at least ${min}")
.when("discount_type", {
is: DISCOUNT_TYPE_PERCENT_OFF,
then: yup
.number()
.max(
then: (schema) =>
schema.max(
100,
"The amount should be between (0 - 1) when discount type is percent-off.",
),
}),
discount_type: yup.string().required("Discount type is required"),
max_redemptions: yup.number().when("coupon_type", {
is: COUPON_TYPE_PROMO,
then: yup
.number()
.min(1, "Must be at least ${min}")
.required("Number required"),
then: (schema) =>
schema.min(1, "Must be at least ${min}").required("Number required"),
}),
coupon_code: yup.string().when("coupon_type", {
is: COUPON_TYPE_PROMO,
then: yup
.string()
.required("Coupon code is required")
.matches(/^\w+$/, "Only letters, numbers, and underscores allowed"),
then: (schema) =>
schema
.required("Coupon code is required")
.matches(/^\w+$/, "Only letters, numbers, and underscores allowed"),
}),
num_coupon_codes: yup.number().when("coupon_type", {
is: COUPON_TYPE_SINGLE_USE,
then: yup
.number()
.min(1, "Must be at least ${min}")
.required("Number required"),
then: (schema) =>
schema.min(1, "Must be at least ${min}").required("Number required"),
}),
max_redemptions_per_user: yup.number().when("coupon_type", {
is: COUPON_TYPE_PROMO,
then: yup
.number()
.required("Number required")
.min(1, "Must be at least ${min}")
.max(100, "Must be at most ${max}"),
then: (schema) =>
schema
.required("Number required")
.min(1, "Must be at least ${min}")
.max(100, "Must be at most ${max}"),
}),
payment_transaction: yup.string().when("coupon_type", {
is: COUPON_TYPE_SINGLE_USE,
then: yup.string().required("Payment transaction is required"),
then: (schema) => schema.required("Payment transaction is required"),
}),
payment_type: yup.string().when("coupon_type", {
is: COUPON_TYPE_SINGLE_USE,
then: yup.string().required("Payment type is required"),
then: (schema) => schema.required("Payment type is required"),
}),
});

Expand Down
24 changes: 12 additions & 12 deletions static/js/components/forms/ProfileFormFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const legalAddressValidation = yup.object().shape({
.label("State/Territory")
.when("country", {
is: includes(__, COUNTRIES_REQUIRING_STATE),
then: yup.string().required()
then: ()=>yup.string().required("State/Territory is a required field")
}),
country: yup
.string()
Expand All @@ -86,17 +86,17 @@ export const legalAddressValidation = yup.object().shape({
.string()
.label("Zip/Postal Code")
.trim()
.when("country", (country, schema) => {
if (country === US_ALPHA_2) {
return schema.required().matches(US_POSTAL_CODE_REGEX, {
message:
"Postal Code must be formatted as either 'NNNNN' or 'NNNNN-NNNN'"
})
} else if (country === CA_ALPHA_2) {
return schema.required().matches(CA_POSTAL_CODE_REGEX, {
message: "Postal Code must be formatted as 'ANA NAN'"
})
}
.when("country", {
is: US_ALPHA_2,
then: (schema)=>
schema.required().matches(US_POSTAL_CODE_REGEX,
"Postal Code must be formatted as either 'NNNNN' or 'NNNNN-NNNN'"
)
}).when("country",{
is: CA_ALPHA_2,
then: (schema)=>schema.required().matches(CA_POSTAL_CODE_REGEX,
"Postal Code must be formatted as 'ANA NAN'"
)
})
})
})
Expand Down
37 changes: 25 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.5, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.4.4, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.7.2, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.8.7, @babel/runtime@npm:^7.9.2":
"@babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.4.4, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.7.2, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.8.7, @babel/runtime@npm:^7.9.2":
version: 7.25.4
resolution: "@babel/runtime@npm:7.25.4"
dependencies:
Expand Down Expand Up @@ -8091,7 +8091,7 @@ __metadata:
languageName: node
linkType: hard

"lodash-es@npm:^4.17.11, lodash-es@npm:^4.17.14, lodash-es@npm:^4.2.1":
"lodash-es@npm:^4.17.14, lodash-es@npm:^4.2.1":
version: 4.17.21
resolution: "lodash-es@npm:4.17.21"
checksum: 05cbffad6e2adbb331a4e16fbd826e7faee403a1a04873b82b42c0f22090f280839f85b95393f487c1303c8a3d2a010048bf06151a6cbe03eee4d388fb0a12d2
Expand Down Expand Up @@ -8911,7 +8911,7 @@ __metadata:
webpack-cli: ^4.8.0
webpack-dev-middleware: ^5.0.0
webpack-hot-middleware: ^2.25.0
yup: ^0.31.0
yup: ^1.0.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -10054,7 +10054,7 @@ __metadata:
languageName: node
linkType: hard

"property-expr@npm:^2.0.4":
"property-expr@npm:^2.0.5":
version: 2.0.6
resolution: "property-expr@npm:2.0.6"
checksum: 89977f4bb230736c1876f460dd7ca9328034502fd92e738deb40516d16564b850c0bbc4e052c3df88b5b8cd58e51c93b46a94bea049a3f23f4a022c038864cab
Expand Down Expand Up @@ -12324,6 +12324,13 @@ __metadata:
languageName: node
linkType: hard

"tiny-case@npm:^1.0.3":
version: 1.0.3
resolution: "tiny-case@npm:1.0.3"
checksum: 3f7a30c39d5b0e1bc097b0b271bec14eb5b836093db034f35a0de26c14422380b50dc12bfd37498cf35b192f5df06f28a710712c87ead68872a9e37ad6f6049d
languageName: node
linkType: hard

"tiny-invariant@npm:^1.0.2":
version: 1.3.3
resolution: "tiny-invariant@npm:1.3.3"
Expand Down Expand Up @@ -12509,6 +12516,13 @@ __metadata:
languageName: node
linkType: hard

"type-fest@npm:^2.19.0":
version: 2.19.0
resolution: "type-fest@npm:2.19.0"
checksum: a4ef07ece297c9fba78fc1bd6d85dff4472fe043ede98bd4710d2615d15776902b595abf62bd78339ed6278f021235fb28a96361f8be86ed754f778973a0d278
languageName: node
linkType: hard

"type-is@npm:~1.6.18":
version: 1.6.18
resolution: "type-is@npm:1.6.18"
Expand Down Expand Up @@ -13579,15 +13593,14 @@ __metadata:
languageName: node
linkType: hard

"yup@npm:^0.31.0":
version: 0.31.1
resolution: "yup@npm:0.31.1"
"yup@npm:^1.0.0":
version: 1.4.0
resolution: "yup@npm:1.4.0"
dependencies:
"@babel/runtime": ^7.10.5
lodash: ^4.17.20
lodash-es: ^4.17.11
property-expr: ^2.0.4
property-expr: ^2.0.5
tiny-case: ^1.0.3
toposort: ^2.0.2
checksum: 79bf28d6afa4cebcabe3322bb82eec93632289cad47dbe47a89ae067f4438b3a7de8ac2e30977539727510450a4f73ed9051c6d6aa2718d9f1ba6b345179cb7d
type-fest: ^2.19.0
checksum: 20a2ee0c1e891979ca16b34805b3a3be9ab4bea6ea3d2f9005b998b4dc992d0e4d7b53e5f4d8d9423420046630fb44fdf0ecf7e83bc34dd83392bca046c5229d
languageName: node
linkType: hard

0 comments on commit 433b112

Please sign in to comment.