-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbebf9c
commit 681dc2d
Showing
3 changed files
with
27 additions
and
2 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,11 @@ | ||
import * as O from 'fp-ts/Option' | ||
|
||
// O.fromNullable 함수처럼 | ||
// false이면 text값을 Some으로 감싸서 반환하고 | ||
// true이면 None을 반환하는 함수를 만들어보자. | ||
|
||
export function fromSnakeCase(text: string) { | ||
const snakeCaseRegex = /^[a-z0-9]+(_[a-z0-9]+)*$/; | ||
// return snakeCaseRegex.test(text); | ||
return snakeCaseRegex.test(text) ? O.some(text) : O.none | ||
} |
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
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,4 +1,4 @@ | ||
export function isSnakeCase(text: string): boolean { | ||
const snakeCaseRegex = /^[a-z0-9]+(_[a-z0-9]+)*$/; | ||
return snakeCaseRegex.test(text); | ||
} | ||
} |