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
- Add benchmark of AMD 5600X by @orionmiz in #156
- Add benchmark Apple m1 by @a-ryang in #157
- Add benchmark of Apple M1 Pro by @xodud001 in #159
- Complement #155, print NodeJS version by @samchon in #162
- Add benchmark of intel core i7-7700 cpu @ 3.60Ghz by @le2sky in #165
- Benchmark from M1 Max 64G by @pmnxis in #161
- Create Apple M1 Max.md by @cockyb in #163
- Add benchmark of Intel Core i5 by @DavidYang2149 in #160
- New Windows benchmark record with Intel CPU by @luncliff in #166
- Test: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz by @Yaminyam in #167
- Add benchmark for AMD Ryzen 4750u by @bitbinge in #168
- Add benchmark of Intel Core i7-9750H CPU @ 2.60GHz by @Isaac-Lee in #169
- Add Benchmark for AMD Ryzen 9 5900X by @lmogwitz in #170
- Create Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz.md by @tkgka in #172
- Add benchmark for Intel(R) Core(TM) Pop!_OS 22.04 by @MBM1607 in #173
- Close #175, support comment tags by @samchon in #178
- test: add benchmark for AMD EPYC 7551 32-Core Processor by @qpakzk in #177
- benchmark: specify type to avoid TSError by @qpakzk in #176
New Contributors
- @orionmiz made their first contribution in #156
- @a-ryang made their first contribution in #157
- @xodud001 made their first contribution in #159
- @le2sky made their first contribution in #165
- @pmnxis made their first contribution in #161
- @cockyb made their first contribution in #163
- @DavidYang2149 made their first contribution in #160
- @luncliff made their first contribution in #166
- @Yaminyam made their first contribution in #167
- @bitbinge made their first contribution in #168
- @Isaac-Lee made their first contribution in #169
- @lmogwitz made their first contribution in #170
- @tkgka made their first contribution in #172
- @MBM1607 made their first contribution in #173
- @qpakzk made their first contribution in #177
Full Changelog: v3.1.1...v3.2.1