We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to check the value is a integer not number.
integer
number
type integer = number; interface Test { foo: integer; bar: string; } const isTest(obj: any): obj is Test => { if (!Number.isInteger(obj?.foo)) return false; if (typeof obj?.bar !== 'string') return false; return true; } const good = { foo: 1, bar: 'good', }; const bad = { foo: 1.234, bar: 'bad', }; console.log(isTest(good)); // true console.log(isTest(bad)); // false
makes like:
import { is, integer } from 'typescript-is'; interface Test { foo: integer; bar: string; } const good = { foo: 1, bar: 'good', }; const bad = { foo: 1.234, bar: 'bad', }; console.log(is<Test>(good)); // true console.log(is<Test>(bad)); // false
or
import { is, addType } from 'typescript-is'; type integer = number; addType<integer>((obj: any): obj is integer => Number.isInteger(obj)); interface Test { foo: integer; bar: string; } const good = { foo: 1, bar: 'good', }; const bad = { foo: 1.234, bar: 'bad', }; console.log(is<Test>(good)); // true console.log(is<Test>(bad)); // false
The text was updated successfully, but these errors were encountered:
Possible by writing comment:
https://github.com/samchon/typescript-json#comment-tags
Sorry, something went wrong.
No branches or pull requests
I want to check the value is a
integer
notnumber
.makes like:
or
The text was updated successfully, but these errors were encountered: