Answer the question
In order to leave comments, you need to log in
How to validate data types in realtime?
Hello, in addition to https://jsonplaceholder.typicode.com/ in the world there is https://breakingbadapi.com/documentation
(Almost the same, but with obviously made mistakes)
the point is that there is a certain field that should be "intager" according to the type documentation
but in real life there are still options where a space like is added
And this is already parsed into a string, in fact
I have an interface like
"season": "1",
"season": " 1",
export interface episode {
season: number;
}
Answer the question
In order to leave comments, you need to log in
It is for type
validation that you can try this library
https://www.npmjs.com/package/typescript-is
PS
Can I make a validator call parseInt when the field does not match the type from the interface, but in realtime...
export interface episode {
season: number | string;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question