-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api): Secrets with empty names (#738)
Co-authored-by: Rajdip Bhattacharya <agentR47@gmail.com>
- Loading branch information
1 parent
dd89d57
commit 5e9c57f
Showing
3 changed files
with
1,229 additions
and
1,165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Transform } from 'class-transformer' | ||
|
||
export function TrimString() { | ||
return Transform(({ value }) => | ||
typeof value === 'string' ? value?.trim() : value | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,45 @@ | ||
import 'reflect-metadata' | ||
import { Transform, Type } from 'class-transformer' | ||
import { | ||
IsArray, | ||
IsOptional, | ||
IsString, | ||
Length, | ||
ValidateNested | ||
} from 'class-validator' | ||
|
||
export class CreateSecret { | ||
@IsString() | ||
name: string | ||
|
||
@IsString() | ||
@IsOptional() | ||
@Length(0, 100) | ||
note?: string | ||
|
||
@IsString() | ||
@IsOptional() | ||
rotateAfter?: '24' | '168' | '720' | '8760' | 'never' = 'never' | ||
|
||
@IsOptional() | ||
@IsArray() | ||
@ValidateNested({ each: true }) | ||
@Type(() => Entry) | ||
entries?: Entry[] | ||
} | ||
|
||
class Entry { | ||
@IsString() | ||
@Transform(({ value }) => value.trim()) | ||
environmentSlug: string | ||
|
||
@IsString() | ||
@Transform(({ value }) => value.trim()) | ||
value: string | ||
} | ||
import 'reflect-metadata' | ||
import { Transform, Type } from 'class-transformer' | ||
import { | ||
IsArray, | ||
IsNotEmpty, | ||
IsOptional, | ||
IsString, | ||
Length, | ||
ValidateNested | ||
} from 'class-validator' | ||
import { TrimString } from '@/decorators/trim-string.decorator' | ||
|
||
export class CreateSecret { | ||
@IsString() | ||
@IsNotEmpty() | ||
@TrimString() | ||
name: string | ||
|
||
@IsString() | ||
@IsOptional() | ||
@Length(0, 100) | ||
note?: string | ||
|
||
@IsString() | ||
@IsOptional() | ||
rotateAfter?: '24' | '168' | '720' | '8760' | 'never' = 'never' | ||
|
||
@IsOptional() | ||
@IsArray() | ||
@ValidateNested({ each: true }) | ||
@Type(() => Entry) | ||
entries?: Entry[] | ||
} | ||
|
||
class Entry { | ||
@IsString() | ||
@IsNotEmpty() | ||
@TrimString() | ||
environmentSlug: string | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
@TrimString() | ||
value: string | ||
} |
Oops, something went wrong.