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

Type tags on validation functions #782

Merged
merged 1 commit into from
Aug 24, 2023
Merged

Type tags on validation functions #782

merged 1 commit into from
Aug 24, 2023

Conversation

samchon
Copy link
Owner

@samchon samchon commented Aug 24, 2023

From now on, validator functions of typia supports type tags like below. This way would be much safer and convenient than previous comment tags.

Also, as this type tags is much safer and even much easier to compose custom validation feature, stop supporting CustomerValidatorMap. After supporting type tags even in typia.random<T>(), typia.json.application<Types>() and typia.protobuf functions, the new major version v5 would be published.

export type Maximum<Fixed extends number | bigint> = {
    "typia.tag"?: {
        target: Fixed extends number ? "number" : "bigint";
        kind: "maximum";
        value: Fixed;
        validate: `$input <= ${Fixed}`;
    };
};

From now on, validator functions of `typia` supports type tags like below. This way would be much safer and convenient than previous comment tags.

Also, as this type tags is much safer and even much easier to compose custom validation feature, stop supporting `CustomerValidatorMap`.

```typescript
export type Maximum<Fixed extends number | bigint> = {
    "typia.tag"?: {
        target: Fixed extends number ? "number" : "bigint";
        kind: "maximum";
        value: Fixed;
        validate: `$input <= ${Fixed}`;
    };
};
```
@samchon samchon added the enhancement New feature or request label Aug 24, 2023
@samchon samchon self-assigned this Aug 24, 2023
@samchon samchon added this to In progress in V5 Update via automation Aug 24, 2023
@samchon samchon merged commit 7b1956e into v5.0 Aug 24, 2023
3 of 4 checks passed
V5 Update automation moved this from In progress to Done Aug 24, 2023
@samchon samchon deleted the features/tags branch August 24, 2023 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant