Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. export class Person{
  2. name : string = "";
  3. age : string = "";
  4. }
  5.  
  6. function validateParams( params: ( keyof Person)[] ){
  7. const data = {'name': 'josue'};
  8. params.forEach(param=>{
  9. if( !data[param] ){
  10. console.log('error, missing', param);
  11. }
  12. })
  13. }
  14.  
  15. let properties = Object
  16. .getOwnPropertyNames(new Person)
  17. .map( e => { return e as keyof Person });
  18.  
  19. validateParams( [...properties] );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement