Skip to content

Commit ca8ca3b

Browse files
authored
Merge pull request #19 from atls/feat/guard-clause
Feat/guard clause
2 parents bceff77 + 306aaea commit ca8ca3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4780
-334
lines changed

.github/ISSUE_TEMPLATE/bug.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ body:
5858
validations:
5959
required: true
6060

61-
projects: ["atls/11"]
61+
projects: ['atls/11']

.github/ISSUE_TEMPLATE/docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ body:
4141
validations:
4242
required: true
4343

44-
projects: ["atls/11"]
44+
projects: ['atls/11']

.github/ISSUE_TEMPLATE/feature.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ body:
4444
validations:
4545
required: true
4646

47-
projects: ["atls/11"]
47+
projects: ['atls/11']

.pnp.cjs

Lines changed: 2016 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 39 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,40 @@
1+
## (2025-01-06)
12

2-
3-
## (2025-01-06)
4-
5-
6-
* Initial commit ([e16e1b2](https://github.com/atls/common/commit/e16e1b2))
7-
8-
* feature(logger): init logger ([801ae9f](https://github.com/atls/common/commit/801ae9f))
9-
10-
* feature(typeorm-logger): init typeorm-logger ([055df1e](https://github.com/atls/common/commit/055df1e))
11-
12-
* chore: update bug template ([620773c](https://github.com/atls/common/commit/620773c))
13-
14-
* chore: update chore template ([31dd631](https://github.com/atls/common/commit/31dd631))
15-
16-
* chore: update feature template ([592629c](https://github.com/atls/common/commit/592629c))
17-
18-
* chore: update gitignore ([a0c8c64](https://github.com/atls/common/commit/a0c8c64))
19-
20-
* chore(common): publish ([81ca4b4](https://github.com/atls/common/commit/81ca4b4))
21-
22-
* chore(common): publish ([ae8b6a8](https://github.com/atls/common/commit/ae8b6a8))
23-
24-
* chore(common): versions ([cf32cb2](https://github.com/atls/common/commit/cf32cb2))
25-
26-
* chore(common): versions ([8d1bebd](https://github.com/atls/common/commit/8d1bebd))
27-
28-
* feat: help-wanted template ([7a7875f](https://github.com/atls/common/commit/7a7875f))
29-
30-
* feat: husky ([3ca1f9d](https://github.com/atls/common/commit/3ca1f9d))
31-
32-
* feat: updated packages, yarn check pass ([7f3f359](https://github.com/atls/common/commit/7f3f359))
33-
34-
* feat: upgrade environment ([44f2424](https://github.com/atls/common/commit/44f2424))
35-
36-
* feat: upgrade environment ([ba0f24d](https://github.com/atls/common/commit/ba0f24d))
37-
38-
* feat: upgrade environment ([f8fe76b](https://github.com/atls/common/commit/f8fe76b))
39-
40-
* feat: upgrade environment ([fa529ed](https://github.com/atls/common/commit/fa529ed))
41-
42-
* feat: upgrade environment ([93e6981](https://github.com/atls/common/commit/93e6981))
43-
44-
* feat: upgrade environment ([9fcd596](https://github.com/atls/common/commit/9fcd596))
45-
46-
* feat: upgraded ([89f9d2d](https://github.com/atls/common/commit/89f9d2d))
47-
48-
* feat: upgrading to latest build ([c0b655f](https://github.com/atls/common/commit/c0b655f))
49-
50-
* feat(common): bump yarn ([295ae5f](https://github.com/atls/common/commit/295ae5f))
51-
52-
* feat(common): bump yarn ([49eace1](https://github.com/atls/common/commit/49eace1))
53-
54-
* feat(core-errors): init ([8d07bf9](https://github.com/atls/common/commit/8d07bf9))
55-
56-
* feat(github): upgrade actions ([6c2b70d](https://github.com/atls/common/commit/6c2b70d))
57-
58-
* feat(issue-templates): update ([7641286](https://github.com/atls/common/commit/7641286))
59-
60-
* feat(issue-templates): update ([d386af9](https://github.com/atls/common/commit/d386af9))
61-
62-
* feat(issue-templates): update ([7849cee](https://github.com/atls/common/commit/7849cee))
63-
64-
* feat(issue-templates): update ([261f293](https://github.com/atls/common/commit/261f293))
65-
66-
* feat(workflows): update ([9068bb6](https://github.com/atls/common/commit/9068bb6))
67-
68-
* feat(workflows): update ([f98361d](https://github.com/atls/common/commit/f98361d))
69-
70-
* feat(workflows): update ([f5a7d6c](https://github.com/atls/common/commit/f5a7d6c))
71-
72-
* fix: fixed versions ([a9c66ad](https://github.com/atls/common/commit/a9c66ad))
73-
74-
* fix: husky chmod ([41f6b55](https://github.com/atls/common/commit/41f6b55))
75-
76-
* fix: more version updates yarn check passed ([9c3d680](https://github.com/atls/common/commit/9c3d680))
77-
78-
* fix: update eslint ([955c140](https://github.com/atls/common/commit/955c140))
79-
80-
* faet: move typeorm onto parent repo ([07aee97](https://github.com/atls/common/commit/07aee97))
81-
82-
83-
84-
85-
3+
- Initial commit ([e16e1b2](https://github.com/atls/common/commit/e16e1b2))
4+
- feature(logger): init logger ([801ae9f](https://github.com/atls/common/commit/801ae9f))
5+
- feature(typeorm-logger): init typeorm-logger ([055df1e](https://github.com/atls/common/commit/055df1e))
6+
- chore: update bug template ([620773c](https://github.com/atls/common/commit/620773c))
7+
- chore: update chore template ([31dd631](https://github.com/atls/common/commit/31dd631))
8+
- chore: update feature template ([592629c](https://github.com/atls/common/commit/592629c))
9+
- chore: update gitignore ([a0c8c64](https://github.com/atls/common/commit/a0c8c64))
10+
- chore(common): publish ([81ca4b4](https://github.com/atls/common/commit/81ca4b4))
11+
- chore(common): publish ([ae8b6a8](https://github.com/atls/common/commit/ae8b6a8))
12+
- chore(common): versions ([cf32cb2](https://github.com/atls/common/commit/cf32cb2))
13+
- chore(common): versions ([8d1bebd](https://github.com/atls/common/commit/8d1bebd))
14+
- feat: help-wanted template ([7a7875f](https://github.com/atls/common/commit/7a7875f))
15+
- feat: husky ([3ca1f9d](https://github.com/atls/common/commit/3ca1f9d))
16+
- feat: updated packages, yarn check pass ([7f3f359](https://github.com/atls/common/commit/7f3f359))
17+
- feat: upgrade environment ([44f2424](https://github.com/atls/common/commit/44f2424))
18+
- feat: upgrade environment ([ba0f24d](https://github.com/atls/common/commit/ba0f24d))
19+
- feat: upgrade environment ([f8fe76b](https://github.com/atls/common/commit/f8fe76b))
20+
- feat: upgrade environment ([fa529ed](https://github.com/atls/common/commit/fa529ed))
21+
- feat: upgrade environment ([93e6981](https://github.com/atls/common/commit/93e6981))
22+
- feat: upgrade environment ([9fcd596](https://github.com/atls/common/commit/9fcd596))
23+
- feat: upgraded ([89f9d2d](https://github.com/atls/common/commit/89f9d2d))
24+
- feat: upgrading to latest build ([c0b655f](https://github.com/atls/common/commit/c0b655f))
25+
- feat(common): bump yarn ([295ae5f](https://github.com/atls/common/commit/295ae5f))
26+
- feat(common): bump yarn ([49eace1](https://github.com/atls/common/commit/49eace1))
27+
- feat(core-errors): init ([8d07bf9](https://github.com/atls/common/commit/8d07bf9))
28+
- feat(github): upgrade actions ([6c2b70d](https://github.com/atls/common/commit/6c2b70d))
29+
- feat(issue-templates): update ([7641286](https://github.com/atls/common/commit/7641286))
30+
- feat(issue-templates): update ([d386af9](https://github.com/atls/common/commit/d386af9))
31+
- feat(issue-templates): update ([7849cee](https://github.com/atls/common/commit/7849cee))
32+
- feat(issue-templates): update ([261f293](https://github.com/atls/common/commit/261f293))
33+
- feat(workflows): update ([9068bb6](https://github.com/atls/common/commit/9068bb6))
34+
- feat(workflows): update ([f98361d](https://github.com/atls/common/commit/f98361d))
35+
- feat(workflows): update ([f5a7d6c](https://github.com/atls/common/commit/f5a7d6c))
36+
- fix: fixed versions ([a9c66ad](https://github.com/atls/common/commit/a9c66ad))
37+
- fix: husky chmod ([41f6b55](https://github.com/atls/common/commit/41f6b55))
38+
- fix: more version updates yarn check passed ([9c3d680](https://github.com/atls/common/commit/9c3d680))
39+
- fix: update eslint ([955c140](https://github.com/atls/common/commit/955c140))
40+
- faet: move typeorm onto parent repo ([07aee97](https://github.com/atls/common/commit/07aee97))

packages/core-errors/CHANGELOG.md

Lines changed: 40 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,45 @@
1-
2-
31
## <small>0.0.3 (2025-01-07)</small>
4-
5-
6-
* chore(common): versions @atls/core-errors:0.0.1 ([833753a](https://github.com/atls/common/commit/833753a))
7-
8-
* chore(core-errors): release (#17) ([e486cab](https://github.com/atls/common/commit/e486cab)), closes [#17](https://github.com/atls/common/issues/17)
9-
10-
11-
12-
13-
142

3+
- chore(common): versions @atls/core-errors:0.0.1 ([833753a](https://github.com/atls/common/commit/833753a))
4+
- chore(core-errors): release (#17) ([e486cab](https://github.com/atls/common/commit/e486cab)), closes [#17](https://github.com/atls/common/issues/17)
155

166
## <small>0.0.1 (2025-01-06)</small>
17-
18-
19-
* Initial commit ([e16e1b2](https://github.com/atls/common/commit/e16e1b2))
20-
21-
* feature(logger): init logger ([801ae9f](https://github.com/atls/common/commit/801ae9f))
22-
23-
* feature(typeorm-logger): init typeorm-logger ([055df1e](https://github.com/atls/common/commit/055df1e))
24-
25-
* chore: update bug template ([620773c](https://github.com/atls/common/commit/620773c))
26-
27-
* chore: update chore template ([31dd631](https://github.com/atls/common/commit/31dd631))
28-
29-
* chore: update feature template ([592629c](https://github.com/atls/common/commit/592629c))
30-
31-
* chore: update gitignore ([a0c8c64](https://github.com/atls/common/commit/a0c8c64))
32-
33-
* chore(common): publish ([81ca4b4](https://github.com/atls/common/commit/81ca4b4))
34-
35-
* chore(common): publish ([ae8b6a8](https://github.com/atls/common/commit/ae8b6a8))
36-
37-
* chore(common): versions ([cf32cb2](https://github.com/atls/common/commit/cf32cb2))
38-
39-
* chore(common): versions ([8d1bebd](https://github.com/atls/common/commit/8d1bebd))
40-
41-
* feat: help-wanted template ([7a7875f](https://github.com/atls/common/commit/7a7875f))
42-
43-
* feat: husky ([3ca1f9d](https://github.com/atls/common/commit/3ca1f9d))
44-
45-
* feat: updated packages, yarn check pass ([7f3f359](https://github.com/atls/common/commit/7f3f359))
46-
47-
* feat: upgrade environment ([44f2424](https://github.com/atls/common/commit/44f2424))
48-
49-
* feat: upgrade environment ([ba0f24d](https://github.com/atls/common/commit/ba0f24d))
50-
51-
* feat: upgrade environment ([f8fe76b](https://github.com/atls/common/commit/f8fe76b))
52-
53-
* feat: upgrade environment ([fa529ed](https://github.com/atls/common/commit/fa529ed))
54-
55-
* feat: upgrade environment ([93e6981](https://github.com/atls/common/commit/93e6981))
56-
57-
* feat: upgrade environment ([9fcd596](https://github.com/atls/common/commit/9fcd596))
58-
59-
* feat: upgraded ([89f9d2d](https://github.com/atls/common/commit/89f9d2d))
60-
61-
* feat: upgrading to latest build ([c0b655f](https://github.com/atls/common/commit/c0b655f))
62-
63-
* feat(common): bump yarn ([295ae5f](https://github.com/atls/common/commit/295ae5f))
64-
65-
* feat(common): bump yarn ([49eace1](https://github.com/atls/common/commit/49eace1))
66-
67-
* feat(core-errors): init ([8d07bf9](https://github.com/atls/common/commit/8d07bf9))
68-
69-
* feat(github): upgrade actions ([6c2b70d](https://github.com/atls/common/commit/6c2b70d))
70-
71-
* feat(issue-templates): update ([7641286](https://github.com/atls/common/commit/7641286))
72-
73-
* feat(issue-templates): update ([d386af9](https://github.com/atls/common/commit/d386af9))
74-
75-
* feat(issue-templates): update ([7849cee](https://github.com/atls/common/commit/7849cee))
76-
77-
* feat(issue-templates): update ([261f293](https://github.com/atls/common/commit/261f293))
78-
79-
* feat(workflows): update ([9068bb6](https://github.com/atls/common/commit/9068bb6))
80-
81-
* feat(workflows): update ([f98361d](https://github.com/atls/common/commit/f98361d))
82-
83-
* feat(workflows): update ([f5a7d6c](https://github.com/atls/common/commit/f5a7d6c))
84-
85-
* fix: fixed versions ([a9c66ad](https://github.com/atls/common/commit/a9c66ad))
86-
87-
* fix: husky chmod ([41f6b55](https://github.com/atls/common/commit/41f6b55))
88-
89-
* fix: more version updates yarn check passed ([9c3d680](https://github.com/atls/common/commit/9c3d680))
90-
91-
* fix: update eslint ([955c140](https://github.com/atls/common/commit/955c140))
92-
93-
* faet: move typeorm onto parent repo ([07aee97](https://github.com/atls/common/commit/07aee97))
94-
95-
96-
977

98-
8+
- Initial commit ([e16e1b2](https://github.com/atls/common/commit/e16e1b2))
9+
- feature(logger): init logger ([801ae9f](https://github.com/atls/common/commit/801ae9f))
10+
- feature(typeorm-logger): init typeorm-logger ([055df1e](https://github.com/atls/common/commit/055df1e))
11+
- chore: update bug template ([620773c](https://github.com/atls/common/commit/620773c))
12+
- chore: update chore template ([31dd631](https://github.com/atls/common/commit/31dd631))
13+
- chore: update feature template ([592629c](https://github.com/atls/common/commit/592629c))
14+
- chore: update gitignore ([a0c8c64](https://github.com/atls/common/commit/a0c8c64))
15+
- chore(common): publish ([81ca4b4](https://github.com/atls/common/commit/81ca4b4))
16+
- chore(common): publish ([ae8b6a8](https://github.com/atls/common/commit/ae8b6a8))
17+
- chore(common): versions ([cf32cb2](https://github.com/atls/common/commit/cf32cb2))
18+
- chore(common): versions ([8d1bebd](https://github.com/atls/common/commit/8d1bebd))
19+
- feat: help-wanted template ([7a7875f](https://github.com/atls/common/commit/7a7875f))
20+
- feat: husky ([3ca1f9d](https://github.com/atls/common/commit/3ca1f9d))
21+
- feat: updated packages, yarn check pass ([7f3f359](https://github.com/atls/common/commit/7f3f359))
22+
- feat: upgrade environment ([44f2424](https://github.com/atls/common/commit/44f2424))
23+
- feat: upgrade environment ([ba0f24d](https://github.com/atls/common/commit/ba0f24d))
24+
- feat: upgrade environment ([f8fe76b](https://github.com/atls/common/commit/f8fe76b))
25+
- feat: upgrade environment ([fa529ed](https://github.com/atls/common/commit/fa529ed))
26+
- feat: upgrade environment ([93e6981](https://github.com/atls/common/commit/93e6981))
27+
- feat: upgrade environment ([9fcd596](https://github.com/atls/common/commit/9fcd596))
28+
- feat: upgraded ([89f9d2d](https://github.com/atls/common/commit/89f9d2d))
29+
- feat: upgrading to latest build ([c0b655f](https://github.com/atls/common/commit/c0b655f))
30+
- feat(common): bump yarn ([295ae5f](https://github.com/atls/common/commit/295ae5f))
31+
- feat(common): bump yarn ([49eace1](https://github.com/atls/common/commit/49eace1))
32+
- feat(core-errors): init ([8d07bf9](https://github.com/atls/common/commit/8d07bf9))
33+
- feat(github): upgrade actions ([6c2b70d](https://github.com/atls/common/commit/6c2b70d))
34+
- feat(issue-templates): update ([7641286](https://github.com/atls/common/commit/7641286))
35+
- feat(issue-templates): update ([d386af9](https://github.com/atls/common/commit/d386af9))
36+
- feat(issue-templates): update ([7849cee](https://github.com/atls/common/commit/7849cee))
37+
- feat(issue-templates): update ([261f293](https://github.com/atls/common/commit/261f293))
38+
- feat(workflows): update ([9068bb6](https://github.com/atls/common/commit/9068bb6))
39+
- feat(workflows): update ([f98361d](https://github.com/atls/common/commit/f98361d))
40+
- feat(workflows): update ([f5a7d6c](https://github.com/atls/common/commit/f5a7d6c))
41+
- fix: fixed versions ([a9c66ad](https://github.com/atls/common/commit/a9c66ad))
42+
- fix: husky chmod ([41f6b55](https://github.com/atls/common/commit/41f6b55))
43+
- fix: more version updates yarn check passed ([9c3d680](https://github.com/atls/common/commit/9c3d680))
44+
- fix: update eslint ([955c140](https://github.com/atls/common/commit/955c140))
45+
- faet: move typeorm onto parent repo ([07aee97](https://github.com/atls/common/commit/07aee97))

packages/guard-clause/package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@atls/guard-clause",
3+
"version": "0.0.0",
4+
"license": "BSD-3-Clause",
5+
"type": "module",
6+
"exports": {
7+
"./package.json": "./package.json",
8+
".": "./src/index.ts"
9+
},
10+
"main": "src/index.ts",
11+
"files": [
12+
"dist"
13+
],
14+
"scripts": {
15+
"build": "yarn library build",
16+
"prepack": "yarn run build",
17+
"postpack": "rm -rf dist"
18+
},
19+
"dependencies": {
20+
"ajv": "8.17.1",
21+
"validator": "13.12.0"
22+
},
23+
"devDependencies": {
24+
"@types/validator": "13.12.2"
25+
},
26+
"publishConfig": {
27+
"exports": {
28+
"./package.json": "./package.json",
29+
".": {
30+
"import": "./dist/index.js",
31+
"types": "./dist/index.d.ts",
32+
"default": "./dist/index.js"
33+
}
34+
},
35+
"main": "dist/index.js",
36+
"typings": "dist/index.d.ts"
37+
}
38+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2+
export type DecoratorFactoryFn = (target: any, propertyKey: string, parameterIndex: number) => void
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { AbstractGuardExtensionFactoryOptions } from '../../factory/index.js'
2+
import type { DecoratorFactoryFn } from './decorator.interfaces.js'
3+
4+
import { NotEmptyGuardExtensionFactory } from '../../extensions/index.js'
5+
import { GuardFactory } from '../../factory/index.js'
6+
7+
export const EmptyDecoratorFactory = (
8+
parameter: string,
9+
options?: AbstractGuardExtensionFactoryOptions['options']
10+
) =>
11+
(): DecoratorFactoryFn =>
12+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
13+
function Empty(target: any, propertyKey: string, parameterIndex: number): void {
14+
GuardFactory.register(NotEmptyGuardExtensionFactory, target, propertyKey, parameterIndex, {
15+
parameter,
16+
options,
17+
})
18+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { AbstractGuardExtensionFactoryOptions } from '../../factory/index.js'
2+
3+
import { EmptyDecoratorFactory } from './empty.decorator.factory.js'
4+
import { NotBigIntDecoratorFactory } from './not-bigint.decorator.factory.js'
5+
import { NotEnumDecoratorFactory } from './not-enum.decorator.factory.js'
6+
import { NotInstanceDecoratorFactory } from './not-instance.decorator.factory.js'
7+
import { NotIntegerDecoratorFactory } from './not-integer.decorator.factory.js'
8+
import { NotISO4217DecoratorFactory } from './not-iso4217.decorator.factory.js'
9+
import { NotJsonSchemaValidDecoratorFactory } from './not-json-schema-valid.decorator.factory.js'
10+
import { NotNumberBetweenDecoratorFactory } from './not-number-between.decorator.factory.js'
11+
import { NotOneOfDecoratorFactory } from './not-one-of.decorator.factory.js'
12+
import { NotStringLengthBetweenDecoratorFactory } from './not-string-length-between.decorator.factory.js'
13+
import { NotUUIDDecoratorFactory } from './not-uuid.decorator.factory.js'
14+
15+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
16+
const factory = (name: string, options?: AbstractGuardExtensionFactoryOptions['options']) => ({
17+
Empty: EmptyDecoratorFactory(name, options),
18+
NotUUID: NotUUIDDecoratorFactory(name, options),
19+
NotInstance: NotInstanceDecoratorFactory(name, options),
20+
NotNumberBetween: NotNumberBetweenDecoratorFactory(name, options),
21+
NotInteger: NotIntegerDecoratorFactory(name, options),
22+
NotEnum: NotEnumDecoratorFactory(name, options),
23+
NotOneOf: NotOneOfDecoratorFactory(name, options),
24+
NotStringLengthBetween: NotStringLengthBetweenDecoratorFactory(name, options),
25+
NotISO4217: NotISO4217DecoratorFactory(name, options),
26+
NotJsonSchemaValid: NotJsonSchemaValidDecoratorFactory(name, options),
27+
NotBigInt: NotBigIntDecoratorFactory(name, options),
28+
})
29+
30+
export const Against = (
31+
name: string
32+
): ReturnType<typeof factory> & {
33+
Optional: ReturnType<typeof factory>
34+
Each: ReturnType<typeof factory>
35+
} => ({
36+
...factory(name),
37+
Optional: factory(name, { optional: true }),
38+
Each: factory(name, { each: true }),
39+
})

0 commit comments

Comments
 (0)