Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IValidation.IError.data property. #1421

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "7.1.0",
"version": "7.2.0",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/IValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}

export interface IError {
Expand Down
8 changes: 1 addition & 7 deletions src/programmers/ValidateProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,7 @@ const create_output = () =>
ts.factory.createShorthandPropertyAssignment("errors"),
ts.factory.createPropertyAssignment(
"data",
ts.factory.createConditionalExpression(
ts.factory.createIdentifier("success"),
undefined,
ts.factory.createIdentifier("input"),
undefined,
ts.factory.createIdentifier("undefined"),
),
ts.factory.createIdentifier("input"),
),
],
true,
Expand Down
2 changes: 1 addition & 1 deletion test/generate/output/generate_http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export const validateQuery = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down
4 changes: 2 additions & 2 deletions test/generate/output/generate_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ export const validate = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down Expand Up @@ -1707,7 +1707,7 @@ export const validateEquals = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down
4 changes: 2 additions & 2 deletions test/generate/output/generate_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ export const createValidateStringify = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down Expand Up @@ -1101,7 +1101,7 @@ export const createValidateParse = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down
4 changes: 2 additions & 2 deletions test/generate/output/generate_misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ export const createValidateClone = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down Expand Up @@ -1198,7 +1198,7 @@ export const createValidatePrune = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down
6 changes: 3 additions & 3 deletions test/generate/output/generate_notations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ export const createValidateCamel = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down Expand Up @@ -1101,7 +1101,7 @@ export const createValidatePascal = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down Expand Up @@ -1653,7 +1653,7 @@ export const createValidateSnake = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down
4 changes: 2 additions & 2 deletions test/generate/output/generate_plain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ export const createValidate = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down Expand Up @@ -1707,7 +1707,7 @@ export const createValidateEquals = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down
4 changes: 2 additions & 2 deletions test/generate/output/generate_protobuf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ export const createValidateEncode = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down Expand Up @@ -870,7 +870,7 @@ export const createValidateDecode = (() => {
return {
success,
errors,
data: success ? input : undefined,
data: input,
} as any;
}
return {
Expand Down
9 changes: 9 additions & 0 deletions test/src/debug/validate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import typia from "typia";

console.log(
typia.validate<number>("one"),
typia.json.validateStringify<string>(2),
typia.protobuf.validateEncode<{
id: string;
}>({ id: 3 }),
);
2 changes: 2 additions & 0 deletions website/pages/docs/json/parse.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -576,6 +577,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down
2 changes: 2 additions & 0 deletions website/pages/docs/json/stringify.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -240,6 +241,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down
8 changes: 7 additions & 1 deletion website/pages/docs/misc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -611,11 +612,11 @@ export namespace IValidation {
export interface ISuccess<T = unknown> {
success: true;
data: T;
errors: [];
}
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -1115,6 +1116,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -1338,6 +1340,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -1559,6 +1562,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -1840,6 +1844,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -2107,6 +2112,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down
2 changes: 2 additions & 0 deletions website/pages/docs/protobuf/decode.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -683,6 +684,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down
2 changes: 2 additions & 0 deletions website/pages/docs/protobuf/encode.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -550,6 +551,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down
4 changes: 4 additions & 0 deletions website/pages/docs/validators/validate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -226,6 +227,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -442,6 +444,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down Expand Up @@ -668,6 +671,7 @@ export namespace IValidation {
export interface IFailure {
success: false;
errors: IError[];
data: unknown;
}
export interface IError {
path: string;
Expand Down
Loading