From 6e060488a87653ec3555943c1ad4a3d0a171f38d Mon Sep 17 00:00:00 2001 From: yosipy Date: Sun, 28 Jul 2024 20:54:34 +0900 Subject: [PATCH] Rename errorCode to rejectedCode --- .../examples/accepting-specific-file-types.md | 2 +- .../accepting-specific-file-types/Accept.tsx | 2 +- docs/examples/basic-example.md | 2 +- docs/examples/basic-example/Basic.tsx | 2 +- docs/examples/custom-validation.md | 4 +-- .../custom-validation/CustomValidation.tsx | 4 +-- docs/introduction/Introduction.tsx | 2 +- docs/introduction/getting-started.md | 2 +- docs/introduction/hooks-and-components.md | 4 +-- lib/types.ts | 4 +-- lib/utils.test.ts | 30 +++++++++---------- lib/utils.ts | 6 ++-- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/docs/examples/accepting-specific-file-types.md b/docs/examples/accepting-specific-file-types.md index 46aa31c..f423423 100644 --- a/docs/examples/accepting-specific-file-types.md +++ b/docs/examples/accepting-specific-file-types.md @@ -69,7 +69,7 @@ export const Accept: FC = () => {
  • {fileRejection.file.name}
  • ))} diff --git a/docs/examples/accepting-specific-file-types/Accept.tsx b/docs/examples/accepting-specific-file-types/Accept.tsx index 91be23a..ddd53a0 100644 --- a/docs/examples/accepting-specific-file-types/Accept.tsx +++ b/docs/examples/accepting-specific-file-types/Accept.tsx @@ -47,7 +47,7 @@ export const Accept: FC = () => {
  • {fileRejection.file.name}
  • ))} diff --git a/docs/examples/basic-example.md b/docs/examples/basic-example.md index 6334273..c177886 100644 --- a/docs/examples/basic-example.md +++ b/docs/examples/basic-example.md @@ -68,7 +68,7 @@ export const Basic: FC = () => {
  • {fileRejection.file.name}
  • ))} diff --git a/docs/examples/basic-example/Basic.tsx b/docs/examples/basic-example/Basic.tsx index 60a9ffb..7227c57 100644 --- a/docs/examples/basic-example/Basic.tsx +++ b/docs/examples/basic-example/Basic.tsx @@ -46,7 +46,7 @@ export const Basic: FC = () => {
  • {fileRejection.file.name}
  • ))} diff --git a/docs/examples/custom-validation.md b/docs/examples/custom-validation.md index 69f1c2d..f90cfe0 100644 --- a/docs/examples/custom-validation.md +++ b/docs/examples/custom-validation.md @@ -44,7 +44,7 @@ export const CustomValidation: FC = () => { const fileRejection: ClassifiedFile = { status: "rejected", file, - errorCode: "name-too-longer", + rejectedCode: "name-too-longer", } return fileRejection } @@ -93,7 +93,7 @@ export const CustomValidation: FC = () => {
  • {fileRejection.file.name}
  • ))} diff --git a/docs/examples/custom-validation/CustomValidation.tsx b/docs/examples/custom-validation/CustomValidation.tsx index 7383345..9951437 100644 --- a/docs/examples/custom-validation/CustomValidation.tsx +++ b/docs/examples/custom-validation/CustomValidation.tsx @@ -22,7 +22,7 @@ export const CustomValidation: FC = () => { const fileRejection: ClassifiedFile = { status: "rejected", file, - errorCode: "name-too-longer", + rejectedCode: "name-too-longer", } return fileRejection } @@ -71,7 +71,7 @@ export const CustomValidation: FC = () => {
  • {fileRejection.file.name}
  • ))} diff --git a/docs/introduction/Introduction.tsx b/docs/introduction/Introduction.tsx index 514e68e..97986cd 100644 --- a/docs/introduction/Introduction.tsx +++ b/docs/introduction/Introduction.tsx @@ -48,7 +48,7 @@ export const Introduction: FC = () => {
  • {fileRejection.file.name}
  • ))} diff --git a/docs/introduction/getting-started.md b/docs/introduction/getting-started.md index 2992045..98910cf 100644 --- a/docs/introduction/getting-started.md +++ b/docs/introduction/getting-started.md @@ -61,7 +61,7 @@ export const Introduction: FC = () => {
  • {fileRejection.file.name}
  • ))} diff --git a/docs/introduction/hooks-and-components.md b/docs/introduction/hooks-and-components.md index 0f7bd95..7a754fc 100644 --- a/docs/introduction/hooks-and-components.md +++ b/docs/introduction/hooks-and-components.md @@ -50,13 +50,13 @@ export type RejectedCode = "more-than-one-file" | "accept-violations" export type AcceptedClassifiedFile = { status: "accepted" file: File - errorCode: undefined + rejectedCode: undefined } export type RejectedClassifiedFile = { status: "rejected" file: File - errorCode: RejectedCode | string + rejectedCode: RejectedCode | string } export type ClassifiedFile = AcceptedClassifiedFile | RejectedClassifiedFile diff --git a/lib/types.ts b/lib/types.ts index 0177248..ec5d67e 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -3,13 +3,13 @@ export type RejectedCode = "more-than-one-file" | "accept-violations" export type AcceptedClassifiedFile = { status: "accepted" file: File - errorCode: undefined + rejectedCode: undefined } export type RejectedClassifiedFile = { status: "rejected" file: File - errorCode: T + rejectedCode: T } export type ClassifiedFile = diff --git a/lib/utils.test.ts b/lib/utils.test.ts index 05ccb31..edd9225 100644 --- a/lib/utils.test.ts +++ b/lib/utils.test.ts @@ -152,7 +152,7 @@ describe("classifyByAcceptability", () => { const multiple = false describe("If input one file", () => { - test("Status should be accepted and errorCode should be undefined", () => { + test("Status should be accepted and rejectedCode should be undefined", () => { const classifiedFiles = classifyByAcceptability([textFile], { accept: "text/plain", multiple, @@ -161,14 +161,14 @@ describe("classifyByAcceptability", () => { { status: "accepted", file: textFile, - errorCode: undefined, + rejectedCode: undefined, }, ]) }) }) describe("If input multi files", () => { - test("Status should be rejected and errorCode should be more-than-one-file", () => { + test("Status should be rejected and rejectedCode should be more-than-one-file", () => { const classifiedFiles = classifyByAcceptability([textFile, jsFile], { accept: "image/png", multiple, @@ -177,12 +177,12 @@ describe("classifyByAcceptability", () => { { status: "rejected", file: textFile, - errorCode: "more-than-one-file", + rejectedCode: "more-than-one-file", }, { status: "rejected", file: jsFile, - errorCode: "more-than-one-file", + rejectedCode: "more-than-one-file", }, ]) }) @@ -193,7 +193,7 @@ describe("classifyByAcceptability", () => { const multiple = true describe("If input files mimeType is included options.accept", () => { - test("Status should be accepted and errorCode should be undefined", () => { + test("Status should be accepted and rejectedCode should be undefined", () => { const classifiedFiles = classifyByAcceptability([textFile, jsFile], { accept: "text/*", multiple, @@ -202,19 +202,19 @@ describe("classifyByAcceptability", () => { { status: "accepted", file: textFile, - errorCode: undefined, + rejectedCode: undefined, }, { status: "accepted", file: jsFile, - errorCode: undefined, + rejectedCode: undefined, }, ]) }) }) describe("If input file mimeType is not included options.accept", () => { - test("Status should be rejected and errorCode should be accept-violations", () => { + test("Status should be rejected and rejectedCode should be accept-violations", () => { const classifiedFiles = classifyByAcceptability([textFile, jsFile], { accept: "image/png", multiple, @@ -223,12 +223,12 @@ describe("classifyByAcceptability", () => { { status: "rejected", file: textFile, - errorCode: "accept-violations", + rejectedCode: "accept-violations", }, { status: "rejected", file: jsFile, - errorCode: "accept-violations", + rejectedCode: "accept-violations", }, ]) }) @@ -243,17 +243,17 @@ describe("splitClassifiedFiles", () => { { status: "accepted", file: new File(["hoge"], "accepted1.txt", { type: "text/plain" }), - errorCode: undefined, + rejectedCode: undefined, }, { status: "accepted", file: new File(["hoge"], "accepted2.txt", { type: "text/plain" }), - errorCode: undefined, + rejectedCode: undefined, }, { status: "rejected", file: new File(["hoge"], "rejected.txt", { type: "text/plain" }), - errorCode: "accept-violations", + rejectedCode: "accept-violations", }, ] }) @@ -270,7 +270,7 @@ describe("splitClassifiedFiles", () => { { status: "rejected", file: new File(["hoge"], "rejected.txt", { type: "text/plain" }), - errorCode: "accept-violations", + rejectedCode: "accept-violations", }, ]) }) diff --git a/lib/utils.ts b/lib/utils.ts index cb89729..d5f3db0 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -75,7 +75,7 @@ export const classifyByAcceptability = ( return { status: "rejected", file: file, - errorCode: "more-than-one-file", + rejectedCode: "more-than-one-file", } }) @@ -86,13 +86,13 @@ export const classifyByAcceptability = ( classifiedFiles.push({ status: "accepted", file: file, - errorCode: undefined, + rejectedCode: undefined, }) } else { classifiedFiles.push({ status: "rejected", file: file, - errorCode: "accept-violations", + rejectedCode: "accept-violations", }) } }