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

Prepare new validation tags utilizing type. #781

Merged
merged 1 commit into from
Aug 23, 2023
Merged

Prepare new validation tags utilizing type. #781

merged 1 commit into from
Aug 23, 2023

Conversation

samchon
Copy link
Owner

@samchon samchon commented Aug 23, 2023

I'm planning to add another way of validation tags utilizing special optional type like below. To support this feature, Metadata must have a break change, and it is the reason why preparing this feature's interface in v5 update, even though this features has not been completed yet.

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

I'm planning to add another way of validation tags utilizing special optional type like below. To support this feature, `Metadata` must have a break change, and it is the reason why preparing this feature's interface in v5 update, even though this features has not been completed yet.

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

const value: number & Maximum<100>;
typia.is(value);
// -> typeof value === "number" && value <= 100;
```
@samchon samchon added documentation Improvements or additions to documentation enhancement New feature or request labels Aug 23, 2023
@samchon samchon self-assigned this Aug 23, 2023
@samchon samchon added this to In progress in V5 Update via automation Aug 23, 2023
@samchon samchon merged commit 941ec5a into v5.0 Aug 23, 2023
1 of 3 checks passed
V5 Update automation moved this from In progress to Done Aug 23, 2023
@samchon samchon deleted the features/tags branch August 23, 2023 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant