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 typescript generic type to functions to ensure type check #2075

Open
wants to merge 396 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
396 commits
Select commit Hold shift + click to select a range
3db79f9
build(deps-dev): bump @types/node from 18.15.11 to 18.15.12 (#2053)
dependabot[bot] Apr 20, 2023
ef22fad
build(deps-dev): bump @types/node from 18.15.12 to 18.15.13 (#2056)
dependabot[bot] Apr 21, 2023
7961e71
build(deps-dev): bump prettier from 2.8.7 to 2.8.8 (#2057)
dependabot[bot] Apr 24, 2023
8bfb718
build(deps-dev): bump eslint from 8.38.0 to 8.39.0 (#2059)
dependabot[bot] Apr 24, 2023
d6d7e23
build(deps-dev): bump @types/node from 18.15.13 to 18.16.0 (#2058)
dependabot[bot] Apr 24, 2023
d91ce19
build(deps-dev): bump @typescript-eslint/eslint-plugin (#2061)
dependabot[bot] Apr 25, 2023
74d6974
build(deps-dev): bump @typescript-eslint/parser from 5.59.0 to 5.59.1…
dependabot[bot] Apr 25, 2023
6b326d5
build(deps-dev): bump @types/node from 18.16.0 to 18.16.1 (#2063)
dependabot[bot] Apr 26, 2023
279600d
build(deps-dev): bump lint-staged from 13.2.1 to 13.2.2 (#2065)
dependabot[bot] Apr 27, 2023
bec2b16
build(deps-dev): bump @types/node from 18.16.1 to 18.16.2 (#2068)
dependabot[bot] Apr 28, 2023
cda03de
build(deps-dev): bump @types/node from 18.16.2 to 18.16.3 (#2071)
dependabot[bot] May 1, 2023
6554294
build(deps-dev): bump @typescript-eslint/parser from 5.59.1 to 5.59.2…
dependabot[bot] May 2, 2023
97cd13f
build(deps-dev): bump @typescript-eslint/eslint-plugin (#2073)
dependabot[bot] May 2, 2023
5e98fa3
build(deps): bump libphonenumber-js from 1.10.28 to 1.10.30 (#2077)
dependabot[bot] May 5, 2023
c4ebedd
build(deps-dev): bump @types/node from 18.16.3 to 20.0.0 (#2076)
dependabot[bot] May 5, 2023
2bcaeb6
build(deps): bump @types/validator from 13.7.15 to 13.7.16 (#2078)
dependabot[bot] May 8, 2023
0dadbe9
build(deps-dev): bump eslint from 8.39.0 to 8.40.0 (#2079)
dependabot[bot] May 8, 2023
754ceea
build(deps-dev): bump @types/node from 20.0.0 to 20.1.0 (#2080)
dependabot[bot] May 8, 2023
91d6400
build(deps-dev): bump @typescript-eslint/eslint-plugin (#2082)
dependabot[bot] May 9, 2023
d662e5d
build(deps-dev): bump @types/node from 20.1.0 to 20.1.1 (#2084)
dependabot[bot] May 9, 2023
cf10be2
build(deps-dev): bump @typescript-eslint/parser from 5.59.2 to 5.59.5…
dependabot[bot] May 9, 2023
52aa2ca
build(deps-dev): bump @types/node from 20.1.1 to 20.1.2 (#2085)
dependabot[bot] May 10, 2023
e178018
build(deps): bump @types/validator from 13.7.16 to 13.7.17 (#2086)
dependabot[bot] May 10, 2023
0dbeadc
build(deps-dev): bump @types/node from 20.1.2 to 20.1.3 (#2088)
dependabot[bot] May 12, 2023
7b4263f
build(deps-dev): bump @rollup/plugin-commonjs from 24.1.0 to 25.0.0 (…
dependabot[bot] May 15, 2023
003394d
build(deps-dev): bump @types/node from 20.1.3 to 20.1.4 (#2091)
dependabot[bot] May 15, 2023
a42ea3f
build(deps-dev): bump @types/node from 20.1.4 to 20.1.5 (#2092)
dependabot[bot] May 16, 2023
47630d3
build(deps-dev): bump @typescript-eslint/parser from 5.59.5 to 5.59.6…
dependabot[bot] May 16, 2023
76ca322
build(deps-dev): bump @typescript-eslint/eslint-plugin (#2094)
dependabot[bot] May 16, 2023
ec1b937
build(deps-dev): bump @types/node from 20.1.5 to 20.1.7 (#2095)
dependabot[bot] May 17, 2023
7eff613
build(deps-dev): bump @types/node from 20.1.7 to 20.2.0 (#2096)
dependabot[bot] May 18, 2023
422a2d6
build(deps-dev): bump rimraf from 5.0.0 to 5.0.1 (#2097)
dependabot[bot] May 18, 2023
1a8b716
build(deps-dev): bump @types/node from 20.2.0 to 20.2.1 (#2098)
dependabot[bot] May 19, 2023
7d8d194
build(deps-dev): bump @types/node from 20.2.1 to 20.2.3 (#2102)
dependabot[bot] May 22, 2023
57730e6
build(deps-dev): bump eslint from 8.40.0 to 8.41.0 (#2103)
dependabot[bot] May 22, 2023
41ac3d7
build(deps-dev): bump @typescript-eslint/eslint-plugin (#2105)
dependabot[bot] May 23, 2023
8bd5b80
build(deps-dev): bump @typescript-eslint/parser from 5.59.6 to 5.59.7…
dependabot[bot] May 23, 2023
c714717
build(deps-dev): bump @types/node from 20.2.3 to 20.2.4 (#2108)
dependabot[bot] May 26, 2023
afbd2dd
build(deps): bump libphonenumber-js from 1.10.30 to 1.10.31 (#2110)
dependabot[bot] May 29, 2023
878bea3
build(deps-dev): bump @types/node from 20.2.4 to 20.2.5 (#2109)
dependabot[bot] May 29, 2023
d3b5628
build(deps-dev): bump @typescript-eslint/eslint-plugin (#2111)
dependabot[bot] May 30, 2023
bdd4703
build(deps-dev): bump @typescript-eslint/parser from 5.59.7 to 5.59.8…
dependabot[bot] May 30, 2023
0c4b793
build(deps-dev): bump @rollup/plugin-node-resolve from 15.0.2 to 15.1…
dependabot[bot] May 31, 2023
1779135
build(deps-dev): bump @types/jest from 29.5.1 to 29.5.2 (#2114)
dependabot[bot] Jun 1, 2023
af97c05
build(deps-dev): bump typescript from 5.0.4 to 5.1.3 (#2115)
dependabot[bot] Jun 2, 2023
05ea010
build(deps-dev): bump @typescript-eslint/parser from 5.59.8 to 5.59.9…
dependabot[bot] Jun 6, 2023
82efb32
build(deps-dev): bump eslint from 8.41.0 to 8.42.0 (#2117)
dependabot[bot] Jun 6, 2023
d8f5938
build(deps): bump libphonenumber-js from 1.10.31 to 1.10.34 (#2120)
dependabot[bot] Jun 6, 2023
5e04b05
build(deps-dev): bump @typescript-eslint/eslint-plugin (#2119)
dependabot[bot] Jun 6, 2023
18791ef
build(deps-dev): bump @rollup/plugin-commonjs from 25.0.0 to 25.0.1 (…
dependabot[bot] Jun 12, 2023
e6f93b8
build(deps-dev): bump @types/node from 20.2.5 to 20.3.0 (#2124)
dependabot[bot] Jun 12, 2023
8a9a050
build(deps-dev): bump @typescript-eslint/eslint-plugin (#2126)
dependabot[bot] Jun 13, 2023
376c4c2
build(deps-dev): bump @types/node from 20.3.0 to 20.3.1 (#2128)
dependabot[bot] Jun 13, 2023
3d28c5f
build(deps-dev): bump @typescript-eslint/parser from 5.59.9 to 5.59.1…
dependabot[bot] Jun 13, 2023
1505a7b
build(deps): bump libphonenumber-js from 1.10.34 to 1.10.36 (#2129)
dependabot[bot] Jun 15, 2023
75d7185
build(deps-dev): bump eslint from 8.42.0 to 8.43.0 (#2131)
dependabot[bot] Jun 19, 2023
2623b81
build(deps-dev): bump eslint-plugin-jest from 27.2.1 to 27.2.2 (#2132)
dependabot[bot] Jun 19, 2023
0444509
build(deps-dev): bump @typescript-eslint/parser from 5.59.11 to 5.60.…
dependabot[bot] Jun 20, 2023
c37fe18
build(deps-dev): bump @rollup/plugin-commonjs from 25.0.1 to 25.0.2 (…
dependabot[bot] Jun 20, 2023
30ee53f
build(deps-dev): bump @typescript-eslint/eslint-plugin (#2139)
dependabot[bot] Jun 27, 2023
301afe3
build(deps-dev): bump @types/node from 20.3.1 to 20.3.2 (#2141)
dependabot[bot] Jun 27, 2023
b219e48
build(deps-dev): bump @typescript-eslint/parser from 5.60.0 to 5.60.1…
dependabot[bot] Jun 27, 2023
9867e0a
build(deps-dev): bump lint-staged from 13.2.2 to 13.2.3 (#2142)
dependabot[bot] Jun 28, 2023
08fe80d
build(deps-dev): bump typescript from 5.1.3 to 5.1.5 (#2143)
dependabot[bot] Jun 28, 2023
22eb8d8
build(deps-dev): bump typescript from 5.1.5 to 5.1.6 (#2144)
dependabot[bot] Jun 29, 2023
3f54c12
build(deps): bump libphonenumber-js from 1.10.36 to 1.10.37 (#2145)
dependabot[bot] Jun 29, 2023
6bba5a9
build(deps-dev): bump ts-jest from 29.1.0 to 29.1.1 (#2147)
dependabot[bot] Jun 30, 2023
8027db1
build(deps-dev): bump eslint from 8.43.0 to 8.44.0 (#2149)
dependabot[bot] Jul 3, 2023
bb13e35
build(deps-dev): bump @types/node from 20.3.2 to 20.3.3 (#2150)
dependabot[bot] Jul 3, 2023
5004dc7
build(deps-dev): bump @typescript-eslint/parser from 5.60.1 to 5.61.0…
dependabot[bot] Jul 4, 2023
200e6f2
build(deps-dev): bump @typescript-eslint/eslint-plugin (#2151)
dependabot[bot] Jul 4, 2023
bff0cc5
build(deps-dev): bump jest from 29.5.0 to 29.6.0 (#2153)
dependabot[bot] Jul 5, 2023
2076b38
build(deps-dev): bump @types/node from 20.3.3 to 20.4.0 (#2155)
dependabot[bot] Jul 6, 2023
e65495a
build(deps-dev): bump jest from 29.6.0 to 29.6.1 (#2156)
dependabot[bot] Jul 7, 2023
63c55ef
build(deps-dev): bump @types/node from 20.4.0 to 20.4.1 (#2158)
dependabot[bot] Jul 10, 2023
1b62521
build(deps-dev): bump @typescript-eslint/parser from 5.61.0 to 5.62.0…
dependabot[bot] Jul 11, 2023
72c4161
build(deps-dev): bump @types/jest from 29.5.2 to 29.5.3 (#2162)
dependabot[bot] Jul 11, 2023
4639f93
build(deps-dev): bump @types/node from 20.4.1 to 20.4.2 (#2164)
dependabot[bot] Jul 13, 2023
4a0ec66
build(deps-dev): bump eslint-plugin-jest from 27.2.2 to 27.2.3 (#2165)
dependabot[bot] Jul 14, 2023
46bb0a6
build(deps-dev): bump eslint from 8.44.0 to 8.45.0 (#2167)
dependabot[bot] Jul 17, 2023
0f23196
build(deps-dev): bump @rollup/plugin-commonjs from 25.0.2 to 25.0.3 (…
dependabot[bot] Jul 17, 2023
2a08a8f
build(deps-dev): bump @types/node from 20.4.2 to 20.4.4 (#2172)
dependabot[bot] Jul 24, 2023
d70d7dc
build(deps-dev): bump @types/node from 20.4.4 to 20.4.5 (#2174)
dependabot[bot] Jul 26, 2023
878fa70
build(deps): bump libphonenumber-js from 1.10.37 to 1.10.38 (#2175)
dependabot[bot] Jul 27, 2023
07f3c8f
build(deps-dev): bump eslint-config-prettier from 8.8.0 to 8.9.0 (#2176)
dependabot[bot] Jul 28, 2023
e5674b6
build(deps-dev): bump jest from 29.6.1 to 29.6.2 (#2177)
dependabot[bot] Jul 28, 2023
fd42826
build(deps-dev): bump eslint from 8.45.0 to 8.46.0 (#2178)
dependabot[bot] Jul 31, 2023
4844dcd
build(deps): bump @types/validator from 13.7.17 to 13.9.0 (#2180)
dependabot[bot] Aug 1, 2023
63a9451
build(deps): bump libphonenumber-js from 1.10.38 to 1.10.39 (#2185)
dependabot[bot] Aug 3, 2023
255bc7b
build(deps-dev): bump @types/node from 20.4.5 to 20.4.6 (#2187)
dependabot[bot] Aug 3, 2023
5a0a8e9
build(deps-dev): bump eslint-config-prettier from 8.9.0 to 8.10.0 (#2…
dependabot[bot] Aug 3, 2023
a4e231e
build(deps-dev): bump @types/node from 20.4.6 to 20.4.7 (#2190)
dependabot[bot] Aug 4, 2023
41c2c4a
build(deps-dev): bump eslint-config-prettier from 8.10.0 to 9.0.0 (#2…
dependabot[bot] Aug 7, 2023
d74d639
build(deps-dev): bump @types/node from 20.4.7 to 20.4.8 (#2193)
dependabot[bot] Aug 7, 2023
a6df255
build(deps-dev): bump @types/node from 20.4.8 to 20.4.9 (#2197)
dependabot[bot] Aug 9, 2023
b7816dc
build(deps-dev): bump eslint from 8.46.0 to 8.47.0 (#2200)
dependabot[bot] Aug 14, 2023
55d2e68
build(deps-dev): bump @rollup/plugin-commonjs from 25.0.3 to 25.0.4 (…
dependabot[bot] Aug 14, 2023
29b75d3
build(deps-dev): bump @types/node from 20.4.9 to 20.5.0 (#2202)
dependabot[bot] Aug 15, 2023
acee137
build(deps-dev): bump lint-staged from 13.2.3 to 14.0.0 (#2204)
dependabot[bot] Aug 15, 2023
c3d561c
build(deps): bump libphonenumber-js from 1.10.39 to 1.10.41 (#2205)
dependabot[bot] Aug 15, 2023
8c80c48
build(deps-dev): bump @rollup/plugin-node-resolve from 15.1.0 to 15.2…
dependabot[bot] Aug 17, 2023
262a3c6
build(deps-dev): bump @types/node from 20.5.0 to 20.5.1 (#2208)
dependabot[bot] Aug 21, 2023
b3c119e
build(deps-dev): bump @rollup/plugin-node-resolve from 15.2.0 to 15.2…
dependabot[bot] Aug 22, 2023
6aac549
build(deps-dev): bump jest from 29.6.2 to 29.6.3 (#2212)
dependabot[bot] Aug 22, 2023
80fdfd3
build(deps-dev): bump lint-staged from 14.0.0 to 14.0.1 (#2215)
dependabot[bot] Aug 23, 2023
49f369d
build(deps-dev): bump @types/node from 20.5.1 to 20.5.3 (#2214)
dependabot[bot] Aug 23, 2023
470f8ce
build(deps-dev): bump @types/jest from 29.5.3 to 29.5.4 (#2217)
dependabot[bot] Aug 24, 2023
d9c6c37
build(deps-dev): bump @types/node from 20.5.3 to 20.5.4 (#2216)
dependabot[bot] Aug 24, 2023
ff71e70
build(deps-dev): bump jest from 29.6.3 to 29.6.4 (#2218)
dependabot[bot] Aug 25, 2023
462de4a
build(deps-dev): bump @types/node from 20.5.4 to 20.5.6 (#2219)
dependabot[bot] Aug 25, 2023
951dd1c
build(deps-dev): bump eslint from 8.47.0 to 8.48.0 (#2221)
dependabot[bot] Aug 28, 2023
f27ebae
build(deps-dev): bump typescript from 5.1.6 to 5.2.2 (#2220)
dependabot[bot] Aug 28, 2023
8147b01
build(deps-dev): bump @types/node from 20.5.6 to 20.5.7 (#2222)
dependabot[bot] Aug 28, 2023
febd0b4
build(deps): bump libphonenumber-js from 1.10.41 to 1.10.43 (#2224)
dependabot[bot] Aug 29, 2023
4c42761
build(deps-dev): bump @types/node from 20.5.7 to 20.5.9 (#2229)
dependabot[bot] Sep 4, 2023
87f0fc4
build(deps-dev): bump eslint from 8.48.0 to 8.49.0 (#2236)
dependabot[bot] Sep 11, 2023
e756905
build(deps-dev): bump @types/node from 20.5.9 to 20.6.0 (#2238)
dependabot[bot] Sep 12, 2023
4547a5d
build(deps-dev): bump jest from 29.6.4 to 29.7.0 (#2240)
dependabot[bot] Sep 13, 2023
993efc3
build(deps-dev): bump @types/node from 20.6.0 to 20.6.1 (#2243)
dependabot[bot] Sep 15, 2023
a2aa82d
docs: add link to class-validator-extended (#2004)
pigulla Sep 16, 2023
be0cf5c
build(deps-dev): bump eslint-plugin-jest from 27.2.3 to 27.4.0 (#2245)
dependabot[bot] Sep 18, 2023
f580cf1
build(deps-dev): bump @types/jest from 29.5.4 to 29.5.5 (#2246)
dependabot[bot] Sep 19, 2023
79b287b
build(deps-dev): bump @types/node from 20.6.1 to 20.6.3 (#2249)
dependabot[bot] Sep 20, 2023
29dc7b8
build(deps-dev): bump eslint from 8.49.0 to 8.50.0 (#2250)
dependabot[bot] Sep 25, 2023
ae3a75a
build(deps-dev): bump @types/node from 20.6.3 to 20.7.0 (#2252)
dependabot[bot] Sep 26, 2023
f5dcccf
build(deps): bump libphonenumber-js from 1.10.43 to 1.10.45 (#2255)
dependabot[bot] Sep 27, 2023
acd61e9
build(deps-dev): bump rimraf from 5.0.1 to 5.0.5 (#2256)
dependabot[bot] Sep 27, 2023
ca32c24
build(deps-dev): bump @types/node from 20.7.0 to 20.7.1 (#2258)
dependabot[bot] Sep 28, 2023
d5d49a4
build(deps-dev): bump @types/node from 20.7.1 to 20.8.0 (#2260)
dependabot[bot] Oct 2, 2023
5087830
build(deps-dev): bump eslint-plugin-jest from 27.4.0 to 27.4.2 (#2261)
dependabot[bot] Oct 2, 2023
077ec77
build(deps-dev): bump @types/node from 20.8.0 to 20.8.2 (#2263)
dependabot[bot] Oct 3, 2023
cc019db
build(deps): bump libphonenumber-js from 1.10.45 to 1.10.46 (#2266)
dependabot[bot] Oct 5, 2023
3672999
build(deps-dev): bump @rollup/plugin-commonjs from 25.0.4 to 25.0.5 (…
dependabot[bot] Oct 6, 2023
ca2ff26
build(deps-dev): bump @rollup/plugin-node-resolve from 15.2.1 to 15.2…
dependabot[bot] Oct 6, 2023
8c147bd
build(deps-dev): bump @rollup/plugin-node-resolve from 15.2.2 to 15.2…
dependabot[bot] Oct 9, 2023
233c54f
build(deps-dev): bump eslint from 8.50.0 to 8.51.0 (#2271)
dependabot[bot] Oct 9, 2023
4b90c41
build(deps-dev): bump @types/node from 20.8.2 to 20.8.4 (#2272)
dependabot[bot] Oct 10, 2023
bf61670
build(deps): bump libphonenumber-js from 1.10.46 to 1.10.47 (#2274)
dependabot[bot] Oct 10, 2023
c81ff57
build(deps-dev): bump @types/node from 20.8.4 to 20.8.5 (#2276)
dependabot[bot] Oct 13, 2023
c6c1b3e
build(deps-dev): bump lint-staged from 14.0.1 to 15.0.1 (#2279)
dependabot[bot] Oct 16, 2023
3920c14
build(deps-dev): bump @types/node from 20.8.5 to 20.8.6 (#2278)
dependabot[bot] Oct 16, 2023
bac079f
build(deps-dev): bump @rollup/plugin-commonjs from 25.0.5 to 25.0.7 (…
dependabot[bot] Oct 17, 2023
0f77214
build(deps-dev): bump @babel/traverse from 7.20.1 to 7.23.2 (#2283)
dependabot[bot] Oct 17, 2023
ae97d2a
build(deps): bump libphonenumber-js from 1.10.47 to 1.10.48 (#2282)
dependabot[bot] Oct 17, 2023
dca2cd3
build(deps-dev): bump @types/jest from 29.5.5 to 29.5.6 (#2285)
dependabot[bot] Oct 18, 2023
9b5669d
build(deps-dev): bump @types/node from 20.8.6 to 20.8.7 (#2286)
dependabot[bot] Oct 19, 2023
b8f5d38
build(deps-dev): bump lint-staged from 15.0.1 to 15.0.2 (#2287)
dependabot[bot] Oct 20, 2023
3e09c3f
build(deps-dev): bump eslint-plugin-jest from 27.4.2 to 27.4.3 (#2288)
dependabot[bot] Oct 23, 2023
bd42471
build(deps-dev): bump eslint from 8.51.0 to 8.52.0 (#2289)
dependabot[bot] Oct 23, 2023
ab0f6ce
build(deps-dev): bump @types/node from 20.8.7 to 20.8.8 (#2291)
dependabot[bot] Oct 24, 2023
9dbb55d
build(deps-dev): bump @types/node from 20.8.8 to 20.8.9 (#2292)
dependabot[bot] Oct 26, 2023
75afb42
build(deps-dev): bump eslint-plugin-jest from 27.4.3 to 27.6.0 (#2294)
dependabot[bot] Oct 27, 2023
157e6e0
build(deps-dev): bump @types/jest from 29.5.6 to 29.5.7 (#2298)
dependabot[bot] Oct 31, 2023
7b7e267
build(deps-dev): bump @types/node from 20.8.9 to 20.8.10 (#2299)
dependabot[bot] Nov 1, 2023
08779e4
build(deps-dev): bump eslint from 8.52.0 to 8.53.0 (#2301)
dependabot[bot] Nov 6, 2023
3c955fd
build(deps): bump libphonenumber-js from 1.10.48 to 1.10.49 (#2295)
dependabot[bot] Nov 6, 2023
d62539b
build(deps-dev): bump @types/node from 20.8.10 to 20.9.0 (#2303)
dependabot[bot] Nov 8, 2023
6a0d341
build(deps-dev): bump @types/jest from 29.5.7 to 29.5.8 (#2304)
dependabot[bot] Nov 8, 2023
7303253
build(deps-dev): bump lint-staged from 15.0.2 to 15.1.0 (#2306)
dependabot[bot] Nov 13, 2023
78a0c5f
build(deps-dev): bump @types/node from 20.9.0 to 20.9.1 (#2308)
dependabot[bot] Nov 17, 2023
442fb4a
build(deps-dev): bump @types/node from 20.9.1 to 20.9.2 (#2309)
dependabot[bot] Nov 20, 2023
24dfbdc
build(deps-dev): bump eslint from 8.53.0 to 8.54.0 (#2310)
dependabot[bot] Nov 20, 2023
9c2b8d4
build(deps-dev): bump @types/jest from 29.5.8 to 29.5.9 (#2311)
dependabot[bot] Nov 21, 2023
ba7e6ce
build(deps-dev): bump typescript from 5.2.2 to 5.3.2 (#2313)
dependabot[bot] Nov 21, 2023
75f2e11
build(deps-dev): bump @types/node from 20.9.2 to 20.9.4 (#2314)
dependabot[bot] Nov 22, 2023
768d926
build(deps-dev): bump @types/jest from 29.5.9 to 29.5.10 (#2315)
dependabot[bot] Nov 22, 2023
ceb5502
build(deps): bump libphonenumber-js from 1.10.49 to 1.10.50 (#2316)
dependabot[bot] Nov 23, 2023
4b585d1
build(deps-dev): bump @types/node from 20.9.4 to 20.10.0 (#2318)
dependabot[bot] Nov 24, 2023
0b50d8d
build(deps): bump libphonenumber-js from 1.10.50 to 1.10.51 (#2319)
dependabot[bot] Nov 24, 2023
51d5bd1
docs: update JSDoc default value for forbidUnknownValues (#2322)
aashutoshrathi Nov 30, 2023
74fd3ae
fix wrong properties in documentation comment (#2277)
holuborhee Nov 30, 2023
6a46b19
build(deps-dev): bump @types/node from 20.10.0 to 20.10.1 (#2323)
dependabot[bot] Nov 30, 2023
1525f82
build(deps-dev): bump lint-staged from 15.1.0 to 15.2.0 (#2324)
dependabot[bot] Dec 4, 2023
391f935
build(deps-dev): bump eslint from 8.54.0 to 8.55.0 (#2325)
dependabot[bot] Dec 4, 2023
b8ca020
build(deps-dev): bump @types/node from 20.10.1 to 20.10.3 (#2329)
dependabot[bot] Dec 5, 2023
f84ebec
build(deps-dev): bump eslint-config-prettier from 9.0.0 to 9.1.0 (#2331)
dependabot[bot] Dec 5, 2023
08f5d30
build(deps-dev): bump @types/jest from 29.5.10 to 29.5.11 (#2332)
dependabot[bot] Dec 6, 2023
2363e02
build(deps-dev): bump typescript from 5.3.2 to 5.3.3 (#2333)
dependabot[bot] Dec 7, 2023
5d12286
build(deps-dev): bump @types/node from 20.10.3 to 20.10.4 (#2334)
dependabot[bot] Dec 7, 2023
5ea098f
build(deps-dev): bump reflect-metadata from 0.1.13 to 0.1.14 (#2336)
dependabot[bot] Dec 8, 2023
ddfc095
build(deps-dev): bump ts-node from 10.9.1 to 10.9.2 (#2338)
dependabot[bot] Dec 11, 2023
675e93a
build(deps-dev): bump reflect-metadata from 0.1.14 to 0.2.0 (#2341)
dependabot[bot] Dec 14, 2023
6cbf5a1
refactor: more concise typings for isDefined utility function (#2159)
reybok Dec 15, 2023
6ec565f
build(deps-dev): bump reflect-metadata from 0.2.0 to 0.2.1 (#2342)
dependabot[bot] Dec 15, 2023
524a8a8
build(deps-dev): bump @types/node from 20.10.4 to 20.10.5 (#2343)
dependabot[bot] Dec 18, 2023
b678270
build(deps): bump libphonenumber-js from 1.10.51 to 1.10.52 (#2344)
dependabot[bot] Dec 18, 2023
5be4cba
build(deps-dev): bump eslint from 8.55.0 to 8.56.0 (#2346)
dependabot[bot] Dec 19, 2023
3ab54c4
build(deps): bump libphonenumber-js from 1.10.52 to 1.10.53 (#2348)
dependabot[bot] Dec 28, 2023
d16211c
build(deps-dev): bump @types/node from 20.10.5 to 20.10.6 (#2351)
dependabot[bot] Jan 1, 2024
6d176e2
build(deps-dev): bump eslint-plugin-jest from 27.6.0 to 27.6.1 (#2353)
dependabot[bot] Jan 2, 2024
e8f3c8a
build(deps-dev): bump @types/node from 20.10.6 to 20.10.7 (#2355)
dependabot[bot] Jan 8, 2024
b76fab3
build(deps-dev): bump eslint-plugin-jest from 27.6.1 to 27.6.2 (#2358)
dependabot[bot] Jan 10, 2024
611f833
build(deps-dev): bump @types/node from 20.10.7 to 20.10.8 (#2359)
dependabot[bot] Jan 10, 2024
0042559
Fix validator imports (#2360)
benasher44 Jan 11, 2024
19f290f
build(deps-dev): bump @types/node from 20.10.8 to 20.11.0 (#2369)
dependabot[bot] Jan 11, 2024
0a18ea2
[UPDATE] bump repo version (#2372)
uboat46 Jan 12, 2024
adffae3
bump package-lock version from 0.14.0 to 0.14.1 (#2375)
sph3rex Jan 12, 2024
9c49bd6
fix: forbidUnknownValues should default true when validatorOptions un…
cduff Jan 15, 2024
e40571f
fix: Add ValidationMetadata.name to IsOptional (#2044)
Clashsoft Jan 15, 2024
afd5eb4
build(deps-dev): bump @types/node from 20.11.0 to 20.11.1 (#2379)
dependabot[bot] Jan 15, 2024
5670145
build(deps-dev): bump eslint-plugin-jest from 27.6.2 to 27.6.3 (#2380)
dependabot[bot] Jan 15, 2024
082e01e
build(deps-dev): bump @types/node from 20.11.1 to 20.11.4 (#2382)
dependabot[bot] Jan 16, 2024
5df5e9b
build(deps-dev): bump @types/node from 20.11.4 to 20.11.5 (#2385)
dependabot[bot] Jan 17, 2024
8724a7a
build(deps): bump libphonenumber-js from 1.10.53 to 1.10.54 (#2387)
dependabot[bot] Jan 22, 2024
2f04cd1
build(deps-dev): bump ts-jest from 29.1.1 to 29.1.2 (#2389)
dependabot[bot] Jan 23, 2024
ff6a2f0
build(deps-dev): bump @types/node from 20.11.5 to 20.11.6 (#2391)
dependabot[bot] Jan 24, 2024
5ad0ef5
build(deps-dev): bump @types/node from 20.11.6 to 20.11.7 (#2392)
dependabot[bot] Jan 26, 2024
ea7b554
build(deps-dev): bump @types/node from 20.11.7 to 20.11.10 (#2394)
dependabot[bot] Jan 29, 2024
7f601e7
build(deps-dev): bump @types/node from 20.11.10 to 20.11.13 (#2397)
dependabot[bot] Jan 31, 2024
ccf1f62
build(deps-dev): bump lint-staged from 15.2.0 to 15.2.1 (#2398)
dependabot[bot] Jan 31, 2024
a6d65e2
build(deps-dev): bump @types/node from 20.11.13 to 20.11.15 (#2400)
dependabot[bot] Feb 1, 2024
19fac9e
build(deps-dev): bump @types/node from 20.11.15 to 20.11.16 (#2402)
dependabot[bot] Feb 2, 2024
dbfcb35
build(deps-dev): bump @types/jest from 29.5.11 to 29.5.12 (#2403)
dependabot[bot] Feb 2, 2024
4b5c3bc
build(deps): bump libphonenumber-js from 1.10.54 to 1.10.55 (#2404)
dependabot[bot] Feb 5, 2024
2247184
build(deps-dev): bump lint-staged from 15.2.1 to 15.2.2 (#2408)
dependabot[bot] Feb 6, 2024
baf558a
build(deps-dev): bump @types/node from 20.11.16 to 20.11.17 (#2410)
dependabot[bot] Feb 9, 2024
76a9808
build(deps-dev): bump @typescript-eslint/eslint-plugin (#2411)
dependabot[bot] Feb 13, 2024
7a010c0
build(deps-dev): bump eslint-plugin-jest from 27.6.3 to 27.8.0 (#2412)
dependabot[bot] Feb 14, 2024
1060c0c
build(deps): bump libphonenumber-js from 1.10.55 to 1.10.56 (#2413)
dependabot[bot] Feb 15, 2024
6de99ff
build(deps-dev): bump @types/node from 20.11.17 to 20.11.19 (#2414)
dependabot[bot] Feb 16, 2024
bfac4ea
build(deps-dev): bump eslint-plugin-jest from 27.8.0 to 27.9.0 (#2416)
dependabot[bot] Feb 19, 2024
f4c9d7d
build(deps-dev): bump @types/node from 20.11.19 to 20.11.20 (#2418)
dependabot[bot] Feb 23, 2024
2404129
build(deps-dev): bump eslint from 8.56.0 to 8.57.0 (#2420)
dependabot[bot] Feb 26, 2024
bb7aa02
build(deps): bump libphonenumber-js from 1.10.56 to 1.10.57 (#2421)
dependabot[bot] Feb 26, 2024
a53e375
build(deps-dev): bump @types/node from 20.11.20 to 20.11.21 (#2424)
dependabot[bot] Feb 28, 2024
7b2e8be
build(deps-dev): bump @types/node from 20.11.21 to 20.11.22 (#2425)
dependabot[bot] Feb 29, 2024
4d39c7c
build(deps-dev): bump @types/node from 20.11.22 to 20.11.24 (#2426)
dependabot[bot] Mar 1, 2024
1107ad4
build(deps-dev): bump @types/node from 20.11.24 to 20.11.25 (#2427)
dependabot[bot] Mar 7, 2024
eb6788d
build(deps-dev): bump typescript from 5.3.3 to 5.4.2 (#2428)
dependabot[bot] Mar 7, 2024
95a9912
build(deps): bump libphonenumber-js from 1.10.57 to 1.10.58 (#2430)
dependabot[bot] Mar 12, 2024
cc24524
build(deps-dev): bump @types/node from 20.11.25 to 20.11.26 (#2431)
dependabot[bot] Mar 12, 2024
5d3b511
build(deps-dev): bump @types/node from 20.11.26 to 20.11.27 (#2435)
dependabot[bot] Mar 14, 2024
795d8ff
build(deps-dev): bump @types/node from 20.11.27 to 20.11.28 (#2436)
dependabot[bot] Mar 15, 2024
2ab6618
Fix Typo in MaxDate comment (#2423)
namandeep-123 Mar 19, 2024
ecae861
build(deps-dev): bump @types/node from 20.11.28 to 20.11.29 (#2437)
dependabot[bot] Mar 19, 2024
573942d
build(deps-dev): bump @types/node from 20.11.29 to 20.11.30 (#2438)
dependabot[bot] Mar 20, 2024
32bbd7d
build(deps-dev): bump typescript from 5.4.2 to 5.4.3 (#2439)
dependabot[bot] Mar 21, 2024
0853341
build(deps): bump libphonenumber-js from 1.10.58 to 1.10.59 (#2442)
dependabot[bot] Mar 26, 2024
aae07db
build(deps-dev): bump reflect-metadata from 0.2.1 to 0.2.2 (#2449)
dependabot[bot] Mar 29, 2024
f68eada
build(deps-dev): bump @types/node from 20.11.30 to 20.12.2 (#2450)
dependabot[bot] Apr 1, 2024
3aa4aaa
build(deps-dev): bump @types/node from 20.12.2 to 20.12.3 (#2451)
dependabot[bot] Apr 3, 2024
8be07fc
build(deps-dev): bump @types/node from 20.12.3 to 20.12.4 (#2452)
dependabot[bot] Apr 4, 2024
6095639
build(deps-dev): bump typescript from 5.4.3 to 5.4.5 (#2458)
dependabot[bot] Apr 11, 2024
169caaa
build(deps): bump libphonenumber-js from 1.10.59 to 1.10.60 (#2453)
dependabot[bot] Apr 11, 2024
c43da04
build(deps-dev): bump @types/node from 20.12.4 to 20.12.7 (#2460)
dependabot[bot] Apr 12, 2024
7073223
build(deps): bump libphonenumber-js from 1.10.60 to 1.10.61 (#2463)
dependabot[bot] Apr 22, 2024
8adaa03
build(deps-dev): bump @types/node from 20.12.7 to 20.12.8 (#2469)
dependabot[bot] May 2, 2024
ba60be9
build(deps): bump libphonenumber-js from 1.10.61 to 1.10.62 (#2473)
dependabot[bot] May 6, 2024
b12b00a
build(deps-dev): bump @types/node from 20.12.8 to 20.12.10 (#2475)
dependabot[bot] May 7, 2024
0e14d0c
build(deps): bump libphonenumber-js from 1.10.62 to 1.11.1 (#2476)
dependabot[bot] May 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -29,6 +29,7 @@ _This changelog follows the [keep a changelog][keep-a-changelog]_ format to main

### Changed

- enable `forbidUnknownValues` option by default
- remove documentation about deprecated schema based validation and added warning
- update warning message logged about missing decorator metadata
- update `libphonenumber-js` to `^1.10.14` from `^1.9.43`
Expand Down
249 changes: 124 additions & 125 deletions README.md

Large diffs are not rendered by default.

4,680 changes: 2,795 additions & 1,885 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "class-validator",
"version": "0.14.0",
"version": "0.14.1",
"description": "Decorator-based property validation for classes.",
"author": "TypeStack contributors",
"license": "MIT",
Expand Down Expand Up @@ -36,30 +36,30 @@
"test:ci": "jest --runInBand --no-cache --coverage --verbose"
},
"dependencies": {
"@types/validator": "^13.7.10",
"libphonenumber-js": "^1.10.14",
"validator": "^13.7.0"
"@types/validator": "^13.11.8",
"libphonenumber-js": "^1.11.1",
"validator": "^13.9.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-node-resolve": "^15.0.1",
"@types/jest": "^29.2.4",
"@types/node": "^18.11.12",
"@typescript-eslint/eslint-plugin": "^5.46.0",
"@typescript-eslint/parser": "^5.46.0",
"eslint": "^8.29.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.1.6",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.10",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^27.9.0",
"husky": "^4.3.8",
"jest": "^29.3.1",
"lint-staged": "^13.1.0",
"prettier": "^2.8.1",
"reflect-metadata": "0.1.13",
"rimraf": "3.0.2",
"jest": "^29.7.0",
"lint-staged": "^15.2.2",
"prettier": "^2.8.8",
"reflect-metadata": "0.2.2",
"rimraf": "5.0.5",
"rollup": "^2.79.1",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
}
}
2 changes: 1 addition & 1 deletion src/decorator/common/IsDefined.ts
Expand Up @@ -8,7 +8,7 @@ export const IS_DEFINED = ValidationTypes.IS_DEFINED;
/**
* Checks if value is defined (!== undefined, !== null).
*/
export function isDefined(value: any): boolean {
export function isDefined<T>(value: T | undefined | null): value is T {
return value !== undefined && value !== null;
}

Expand Down
17 changes: 17 additions & 0 deletions src/decorator/common/IsIn.spec.ts
@@ -0,0 +1,17 @@
import { isIn } from './IsIn';

describe('@IsIn decorator implementation', () => {
describe('isIn validator', () => {
it('should accept valid values', () => {
expect(isIn('A', ['A', 'B'])).toBe(true);
expect(isIn('A', ['B', 'C'])).toBe(false);
expect(isIn('A', [1, 2])).toBe(false);
});

it('should not accept invalid values', () => {
expect(isIn('A', 5 as any)).toBe(false);
expect(isIn('A', 'ABC' as any)).toBe(false);
expect(isIn('A', false as any)).toBe(false);
});
});
});
2 changes: 1 addition & 1 deletion src/decorator/common/IsIn.ts
Expand Up @@ -7,7 +7,7 @@ export const IS_IN = 'isIn';
* Checks if given value is in a array of allowed values.
*/
export function isIn(value: unknown, possibleValues: readonly unknown[]): boolean {
return !Array.isArray(possibleValues) || possibleValues.some(possibleValue => possibleValue === value);
return Array.isArray(possibleValues) && possibleValues.some(possibleValue => possibleValue === value);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/decorator/common/IsOptional.ts
Expand Up @@ -4,13 +4,16 @@ import { ValidationTypes } from '../../validation/ValidationTypes';
import { ValidationMetadata } from '../../metadata/ValidationMetadata';
import { getMetadataStorage } from '../../metadata/MetadataStorage';

export const IS_OPTIONAL = 'isOptional';

/**
* Checks if value is missing and if so, ignores all validators.
*/
export function IsOptional(validationOptions?: ValidationOptions): PropertyDecorator {
return function (object: object, propertyName: string): void {
const args: ValidationMetadataArgs = {
type: ValidationTypes.CONDITIONAL_VALIDATION,
name: IS_OPTIONAL,
target: object.constructor,
propertyName: propertyName,
constraints: [
Expand Down
2 changes: 1 addition & 1 deletion src/decorator/date/MaxDate.ts
Expand Up @@ -11,7 +11,7 @@ export function maxDate(date: unknown, maxDate: Date | (() => Date)): boolean {
}

/**
* Checks if the value is a date that's after the specified date.
* Checks if the value is a date that's before the specified date.
*/
export function MaxDate(date: Date | (() => Date), validationOptions?: ValidationOptions): PropertyDecorator {
return ValidateBy(
Expand Down
2 changes: 1 addition & 1 deletion src/decorator/object/IsNotEmptyObject.ts
Expand Up @@ -13,7 +13,7 @@ export function isNotEmptyObject(value: unknown, options?: { nullable?: boolean
return false;
}

if (options?.nullable === true) {
if (options?.nullable === false) {
return !Object.values(value).every(propertyValue => propertyValue === null || propertyValue === undefined);
}

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsAlpha.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isAlphaValidator from 'validator/lib/isAlpha';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_ALPHA = 'isAlpha';

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsAlphanumeric.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isAlphanumericValidator from 'validator/lib/isAlphanumeric';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_ALPHANUMERIC = 'isAlphanumeric';

Expand Down
11 changes: 8 additions & 3 deletions src/decorator/string/IsBase64.ts
@@ -1,25 +1,30 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBase64Validator from 'validator/lib/isBase64';
import * as ValidatorJS from 'validator';

export const IS_BASE64 = 'isBase64';

/**
* Checks if a string is base64 encoded.
* If given value is not a string, then it returns false.
*/
export function isBase64(value: unknown): boolean {
return typeof value === 'string' && isBase64Validator(value);
export function isBase64(value: unknown, options?: ValidatorJS.IsBase64Options): boolean {
return typeof value === 'string' && isBase64Validator(value, options);
}

/**
* Checks if a string is base64 encoded.
* If given value is not a string, then it returns false.
*/
export function IsBase64(validationOptions?: ValidationOptions): PropertyDecorator {
export function IsBase64(
options?: ValidatorJS.IsBase64Options,
validationOptions?: ValidationOptions
): PropertyDecorator {
return ValidateBy(
{
name: IS_BASE64,
constraints: [options],
validator: {
validate: (value, args): boolean => isBase64(value),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base64 encoded', validationOptions),
Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsCurrency.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isCurrencyValidator from 'validator/lib/isCurrency';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_CURRENCY = 'isCurrency';

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsDateString.ts
@@ -1,6 +1,6 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';
import { isISO8601 } from './IsISO8601';

export const IS_DATE_STRING = 'isDateString';
Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsDecimal.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isDecimalValidator from 'validator/lib/isDecimal';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_DECIMAL = 'isDecimal';

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsEmail.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isEmailValidator from 'validator/lib/isEmail';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_EMAIL = 'isEmail';

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsFQDN.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isFqdnValidator from 'validator/lib/isFQDN';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_FQDN = 'isFqdn';

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsHash.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isHashValidator from 'validator/lib/isHash';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_HASH = 'isHash';

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsISO8601.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isIso8601Validator from 'validator/lib/isISO8601';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_ISO8601 = 'isIso8601';

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsISSN.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isISSNValidator from 'validator/lib/isISSN';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_ISSN = 'isISSN';

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsIdentityCard.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isIdentityCardValidator from 'validator/lib/isIdentityCard';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_IDENTITY_CARD = 'isIdentityCard';

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsMacAddress.ts
@@ -1,7 +1,7 @@
import { ValidationOptions, isValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isMacAddressValidator from 'validator/lib/isMACAddress';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_MAC_ADDRESS = 'isMacAddress';

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsMobilePhone.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isMobilePhoneValidator from 'validator/lib/isMobilePhone';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_MOBILE_PHONE = 'isMobilePhone';

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsNumberString.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isNumericValidator from 'validator/lib/isNumeric';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_NUMBER_STRING = 'isNumberString';

Expand Down
43 changes: 43 additions & 0 deletions src/decorator/string/IsPhoneNumber.spec.ts
@@ -0,0 +1,43 @@
import { isPhoneNumber } from './IsPhoneNumber';

describe('@IsPhoneNumber decorator implementation', () => {
describe('isPhoneNumber validator', () => {
it('should accept valid values', () => {
expect(isPhoneNumber('+36 20 111 1111')).toBe(true);
expect(isPhoneNumber('+36 20 111 1111', 'HU')).toBe(true);
expect(isPhoneNumber('20 111 1111', 'HU')).toBe(true);
});

describe('should not accept invalid values', () => {
it('xxx', () => {
expect(isPhoneNumber('aaaaa', 'HU')).toBe(false);
expect(isPhoneNumber('aaaa')).toBe(false);
});

it('when country code do not match number', () => {
// US number with Hungarian locale
expect(isPhoneNumber('+1 213 373 4253', 'HU')).toBe(false);
// Hungarian number with US locale
expect(isPhoneNumber('+36 20 111 1111', 'US')).toBe(false);
});

it('when number is invalid in given locale', () => {
expect(isPhoneNumber('+36 00 111 1111', 'HU')).toBe(false);
});

it('when phone number length is incorrect', () => {
expect(isPhoneNumber('+36 20 111 111', 'HU')).toBe(false);
});

it('when there are letters after or before the phone number', () => {
expect(isPhoneNumber('abc +36 20 111 111', 'HU')).toBe(false);
expect(isPhoneNumber('+36 20 111 111 abc', 'HU')).toBe(false);
});
});

it('should not accept values with extra whitespace', () => {
expect(isPhoneNumber(' +36 20 111 1111', 'HU')).toBe(false);
expect(isPhoneNumber('+36 20 111 1111 ', 'HU')).toBe(false);
});
});
});
21 changes: 16 additions & 5 deletions src/decorator/string/IsPhoneNumber.ts
@@ -1,6 +1,6 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import { parsePhoneNumberFromString, CountryCode } from 'libphonenumber-js';
import { parsePhoneNumber, CountryCode } from 'libphonenumber-js/max';

export const IS_PHONE_NUMBER = 'isPhoneNumber';

Expand All @@ -13,12 +13,23 @@ export const IS_PHONE_NUMBER = 'isPhoneNumber';
* If text doesn't start with the international calling code (e.g. +41), then you must set this parameter.
*/
export function isPhoneNumber(value: string, region?: CountryCode): boolean {
if (typeof value !== 'string' || value.trim() !== value) {
return false;
}

try {
const phoneNum = parsePhoneNumberFromString(value, region);
const result = phoneNum?.isValid();
return !!result;
const phoneNumber = parsePhoneNumber(value, region);

/**
* We fail the validation if the user provided a region code
* and it doesn't match with the country code of the parsed number.
**/
if (region && phoneNumber.country !== region) {
return false;
}

return phoneNumber.isValid();
} catch (error) {
// logging?
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsPostalCode.ts
@@ -1,7 +1,7 @@
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isPostalCodeValidator from 'validator/lib/isPostalCode';
import ValidatorJS from 'validator';
import * as ValidatorJS from 'validator';

export const IS_POSTAL_CODE = 'isPostalCode';

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/string/IsStrongPassword.ts
@@ -1,4 +1,4 @@
import validator from 'validator';
import * as validator from 'validator';
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

Expand Down