Skip to content

Releases: samchon/typia

v3.2.5

14 Sep 01:51
dcaeff8
Compare
Choose a tag to compare

What's Changed

  • Fix #191 - index identifier not by random generator but by sequential… by @samchon in #192

Full Changelog: v3.2.4...v3.2.5

v3.2.4

13 Sep 10:09
d795c30
Compare
Choose a tag to compare

What's Changed

Full Changelog: v3.2.3...v3.2.4

v3.2.3

12 Sep 12:08
4427bd3
Compare
Choose a tag to compare

Special thans for @paulrostorp

What's Changed

Full Changelog: v3.2.2...v3.2.3

v3.2.2

10 Sep 12:38
Compare
Choose a tag to compare

What's Changed

Full Changelog: v3.2.1...v3.2.2

New tags:

  • @exclusiveMinimum
  • @exclusiveMaximum
  • @multipleOf
  • @step

v3.2.1

04 Sep 14:23
Compare
Choose a tag to compare

Thanks for many contributors who've participated in benchmark.

Since v3.2 update, typescript-json has started supporting comment tags.

Below table shows list of supported comment tags. You can utilize those tags by writing in comments like below example structure TagExample. Look at them and utilize those comment tags to make your TypeScript program to be safer and more convenient.

Also, don't worry about taking a mistake on using those comment tags. In that case, compile error would be occured. By the compile level error detection, typescript-json is much stronger than any other runtime validator libraries using decorator functions, which can't catch any mistake on the compilation level.

Tag Kind Target Type
@type {"int"|"uint"} number
@range (number, number] number
@minimum {number} number
@maximum {number} number
@length {number} | [number, number) string
@minLength {number} string
@maxLength {number} string
@format {"email"|"uuid"|"url"|"ipv4"|"ipv6"} string
@pattern {string} string
export interface TagExample {
    /* -----------------------------------------------------------
        ARRAYS
    ----------------------------------------------------------- */
    /**
     * You can limit array length like below.
     * 
     * @minItems 3
     * @maxItems 10
     * 
     * Also, you can use `@items` tag instead.
     * 
     * @items (5, 10] --> 5 < length <= 10
     * @items [7      --> 7 <= length
     * @items 12)     --> length < 12
     * 
     * Furthermore, you can use additional tags for each item.
     * 
     * @type uint
     * @format uuid
     */
    array: Array<string|number>;

    /**
     * If two-dimensional array comes, length limit would work for 
     * both 1st and 2nd level arraies. Also using additional tags 
     * for each item (string) would still work.
     * 
     * @items (5, 10)
     * @format url
     */
    matrix: string[][];

    /* -----------------------------------------------------------
        NUMBERS
    ----------------------------------------------------------- */
    /**
     * Type of number.
     * 
     * It must be one of integer or unsigned integer.
     * 
     * @type int
     * @type uint
     */
    type: number;

    /**
     * You can limit range of numeric value like below.
     * 
     * @minimum 5
     * @maximum 10
     * 
     * Also, you can use `@range` tag instead.
     * 
     * @range (5, 10] --> 5 < x <= 10
     * @range [7      --> 7 <= x
     * @range 12)     --> x < 12
     */
    range: number;

    /* -----------------------------------------------------------
        STRINGS
    ----------------------------------------------------------- */
    /**
     * You can limit string length like below.
     * 
     * @minLength 3
     * @maxLength 10
     * 
     * Also, you can use `@length` tag instead.
     * 
     * @length 10      --> length = 10
     * @length [3, 7]  --> 3 <= length && length <= 7
     * @length (5, 10) --> 5 < length && length < 10
     * @length [4      --> 4 < length
     * @length 7)      --> length < 7
     */
    length: string;

    /**
     * Mobile number composed by only numbers.
     * 
     * Note that, `typescript-json` does not support flag of regex,
     * because JSON schema definition does not suppor it either.
     * Therefore, write regex pattern without `/` characters and flag.
     * 
     * @pattern ^0[0-9]{7,16} 
     *     -> RegExp(/[0-9]{7,16}/).test("01012345678")
     */
    mobile: string;

    /**
     * E-mail address.
     * 
     * @format email
     */
    email: string;

    /**
     * UUID value.
     * 
     * @format uuid
     */
    uuid: string;

    /**
     * URL address.
     * 
     * @format url
     */
    url: string;

    /**
     * IPv4 address.
     * 
     * @format ipv4
     */
    ipv4: string;

    /**
     * IPv6 address.
     * 
     * @format ipv6
     */
    ipv6: string;
}

What's Changed

New Contributors

Full Changelog: v3.1.1...v3.2.1

v3.1.1

15 Jul 18:24
9bd4848
Compare
Choose a tag to compare

What's Changed

Full Changelog: v3.0.12...v3.1.1

A new function validate() has come.

The validate() function archives all type errors into an IValidation.errors array, which being returned by the validate() function.

Special thanks for @edobrb who've suggested this validate() function.

export function validate<T>(input: T): IValidation;

export interface IValidation {
    success: boolean;
    errors: IValidation.IError[];
}
export namespace IValidation {
    export interface IError {
        path: string;
        expected: string;
        value: any;
    }
}

v3.0.12

09 Jul 18:21
ff2e95c
Compare
Choose a tag to compare

What's Changed

Full Changelog: v3.0.10...v3.0.12

v3.0.10

05 Jul 17:48
520b042
Compare
Choose a tag to compare

What's Changed

Full Changelog: v3.0.9...v3.0.10

v3.0.9

04 Jul 18:00
0dc17c0
Compare
Choose a tag to compare

What's Changed

Full Changelog: v3.0.8...v3.0.9

v3.0.8

03 Jul 17:40
0317a90
Compare
Choose a tag to compare

What's Changed

Full Changelog: v3.0.7...v3.0.8