Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/studio/src/common/formUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export const commonYupValidation = {
audio: Yup.mixed().required("This field is required"),
barcodeNumber: Yup.string().when("barcodeType", {
is: (barcodeType: string) => !!barcodeType && barcodeType !== NONE_OPTION,
otherwise: Yup.string(),
then: Yup.string()
otherwise: (schema) => schema,
then: (schema) => schema
.test("barcodeNumberTest", function (value = "") {
const { barcodeType } = this.parent;
const { regEx, message } = getBarcodeRegex(barcodeType);
Expand All @@ -106,7 +106,7 @@ export const commonYupValidation = {
creditors: (roles: string[]) =>
Yup.array().when("isMinting", {
is: (value: boolean) => !!value,
then: Yup.array().test({
then: (schema) => schema.test({
message: "Creditors must have a role",
test: (creditors = []) =>
creditors.every(({ role }) => roles.includes(role)),
Expand Down Expand Up @@ -197,7 +197,7 @@ export const commonYupValidation = {
),
owners: Yup.array().when("isMinting", {
is: (value: boolean) => !!value,
then: Yup.array()
then: (schema) => schema
.min(1, "At least one owner is required when minting")
.test({
message: "Owner percentages must be between 00.01% and 100%",
Expand Down
4 changes: 2 additions & 2 deletions apps/studio/src/pages/home/profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ const Profile: FunctionComponent = () => {
companyIpRights: Yup.bool(),
companyName: Yup.string().when("companyIpRights", {
is: true,
otherwise: Yup.string(),
then: Yup.string()
otherwise: (schema) => schema,
then: (schema) => schema
.max(
MAX_CHARACTER_COUNT,
`Must be ${MAX_CHARACTER_COUNT} characters or less`
Expand Down
4 changes: 2 additions & 2 deletions apps/studio/src/pages/home/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Settings: FunctionComponent = () => {
*/
const newPassword = commonYupValidation.newPassword.when("currentPassword", {
is: (currentValue: string) => currentValue,
then: Yup.string()
then: (schema) => schema
.required("New password is required")
.notOneOf(
[Yup.ref("currentPassword")],
Expand All @@ -55,7 +55,7 @@ const Settings: FunctionComponent = () => {
"newPassword",
{
is: (currentValue: string) => currentValue,
then: Yup.string().required("Must match new password"),
then: (schema) => schema.required("Must match new password"),
}
);

Expand Down
Loading
Loading