-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #250 from mrmlnc/ISSUE-247_input_data_validation
ISSUE-247: improve input data validation
- Loading branch information
Showing
5 changed files
with
66 additions
and
20 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
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
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,33 @@ | ||
import * as assert from 'assert'; | ||
|
||
import * as util from './string'; | ||
|
||
describe('Utils → String', () => { | ||
describe('.isString', () => { | ||
it('should return true', () => { | ||
const actual = util.isString(''); | ||
|
||
assert.ok(actual); | ||
}); | ||
|
||
it('should return false', () => { | ||
const actual = util.isString(undefined as unknown as string); | ||
|
||
assert.ok(!actual); | ||
}); | ||
}); | ||
|
||
describe('.isEmpty', () => { | ||
it('should return true', () => { | ||
const actual = util.isEmpty(''); | ||
|
||
assert.ok(actual); | ||
}); | ||
|
||
it('should return false', () => { | ||
const actual = util.isEmpty('string'); | ||
|
||
assert.ok(!actual); | ||
}); | ||
}); | ||
}); |
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 @@ | ||
export function isString(input: unknown): input is string { | ||
return typeof input === 'string'; | ||
} | ||
|
||
export function isEmpty(input: string): boolean { | ||
return input === ''; | ||
} |