-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: #24 객체 동결 기능과 공통 validation 기능 추가
- Loading branch information
Showing
3 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,15 @@ | ||
export default class Validator { | ||
public static isEmptyString(value: string) { | ||
return value.trim().length === 0; | ||
} | ||
|
||
// ToDo: 정말로 공용 Validation 기능인가 생각해보기 | ||
public static isDuplicatedName(nameList: string[], name: string, ignoreCase: boolean = true) { | ||
if (ignoreCase) { | ||
const lowerCaseNameList = nameList.map((n) => n.toLowerCase().trim()); | ||
const lowerCaseName = name.toLowerCase().trim(); | ||
return lowerCaseNameList.includes(lowerCaseName); | ||
} | ||
return nameList.includes(name); | ||
} | ||
} |
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,6 @@ | ||
export const deepFreeze = <T extends object>(obj: T) => { | ||
Object.keys(obj).forEach((prop) => { | ||
if (typeof prop === 'object' && !Object.isFrozen(prop)) deepFreeze(prop); | ||
}); | ||
return Object.freeze(obj); | ||
}; |