I'm using angular 2 at the moment. And I have array of some data
data: MyModel[] = [
{
id: 1,
name: 'Name',
secondName: 'SecondName'
}
Also MyModel is interface:
interface MyModel {
id: number,
name: string,
secondName: string
Let's imagine, that I received data from Back-End(object json):
{
id: 2,
FIRSTname: 'FName',
secondName: 'SecondName'
}
How can I validate, that keys in object are equals to my interface?
For example field "FIRSTname" is incorrect, then I should throw exception or something else.