@dismissible/nestjs-api 0.0.2-canary.c91edbc.0 → 0.0.2-canary.d2f56d7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @dismissible/nestjs-api might be problematic. Click here for more details.

@@ -1,47 +0,0 @@
1
- import 'reflect-metadata';
2
- import { IsBoolean } from 'class-validator';
3
- import { plainToInstance } from 'class-transformer';
4
- import { TransformBoolean } from './transform-boolean.decorator';
5
-
6
- class TestConfig {
7
- @IsBoolean()
8
- @TransformBoolean()
9
- value!: boolean;
10
- }
11
-
12
- describe('TransformBoolean', () => {
13
- it('should transform string "true" to boolean true', () => {
14
- const config = plainToInstance(TestConfig, { value: 'true' });
15
- expect(config.value).toBe(true);
16
- });
17
-
18
- it('should transform string "false" to boolean false', () => {
19
- const config = plainToInstance(TestConfig, { value: 'false' });
20
- expect(config.value).toBe(false);
21
- });
22
-
23
- it('should keep boolean true as true', () => {
24
- const config = plainToInstance(TestConfig, { value: true });
25
- expect(config.value).toBe(true);
26
- });
27
-
28
- it('should keep boolean false as false', () => {
29
- const config = plainToInstance(TestConfig, { value: false });
30
- expect(config.value).toBe(false);
31
- });
32
-
33
- it('should transform other string values to false', () => {
34
- const config = plainToInstance(TestConfig, { value: 'yes' });
35
- expect(config.value).toBe(false);
36
- });
37
-
38
- it('should transform undefined to false', () => {
39
- const config = plainToInstance(TestConfig, { value: undefined });
40
- expect(config.value).toBe(false);
41
- });
42
-
43
- it('should transform null to false', () => {
44
- const config = plainToInstance(TestConfig, { value: null });
45
- expect(config.value).toBe(false);
46
- });
47
- });
@@ -1,19 +0,0 @@
1
- import { Transform } from 'class-transformer';
2
-
3
- /**
4
- * Transforms a string "true" or boolean true to boolean true,
5
- * otherwise returns false.
6
- *
7
- * Useful for environment variable configuration where boolean values
8
- * may be passed as strings.
9
- *
10
- * @example
11
- * // Input: "true" → Output: true
12
- * // Input: true → Output: true
13
- * // Input: "false" → Output: false
14
- * // Input: false → Output: false
15
- * // Input: "anything" → Output: false
16
- */
17
- export function TransformBoolean(): PropertyDecorator {
18
- return Transform(({ value }) => value === true || value === 'true');
19
- }
@@ -1,16 +0,0 @@
1
- import { Transform } from 'class-transformer';
2
-
3
- /**
4
- * Transforms a comma-separated string into an array of trimmed strings.
5
- * If the value is already an array, it is returned as-is.
6
- *
7
- * @example
8
- * // Input: "GET,POST,DELETE" → Output: ["GET", "POST", "DELETE"]
9
- * // Input: "a , b , c" → Output: ["a", "b", "c"]
10
- * // Input: ["a", "b"] → Output: ["a", "b"]
11
- */
12
- export function TransformCommaSeparated(): PropertyDecorator {
13
- return Transform(({ value }) =>
14
- typeof value === 'string' ? value.split(',').map((s) => s.trim()) : value,
15
- );
16
- }