Skip to content

Instantly share code, notes, and snippets.

@ajitid
Last active June 1, 2021 20:53
Show Gist options
  • Save ajitid/cba9581355dd62e742fc97f981f4e975 to your computer and use it in GitHub Desktop.
Save ajitid/cba9581355dd62e742fc97f981f4e975 to your computer and use it in GitHub Desktop.
validate string, number and object
export function isNumber(input: unknown): input is number {
return Number.isFinite(input);
}
export function isString(input: unknown): input is string {
return typeof input === 'string';
}
export function isObject(input: unknown): input is object {
return input !== null && typeof input === 'object';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment