Skip to content

Commit

Permalink
feat: Create checkValues
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Mar 14, 2021
1 parent 39d0f17 commit 319230f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
30 changes: 30 additions & 0 deletions src/api/helpers/layers-interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export interface Scope {
erro: boolean;
to: string;
text: string;
}

function infoType(data: string, type: string) {
return typeof data === type ? true : false;
}
export function checkValuesSender(data: any) {
if (Array.isArray(data)) {
for (let i in data) {
let result =
data[i].type && data[i].value && infoType(data[i].value, data[i].type)
? true
: false;
if (!result) {
return {
erro: true,
param: data[i].param,
function: data[i].function,
text: `Invalid parameter in ${data[i].param}! Pass a variable of type ${data[i].type}!`,
};
}
}
return true;
} else {
console.error('Error: checkValuesSender is not array');
}
}
5 changes: 0 additions & 5 deletions src/api/layers/layers-interface.ts

This file was deleted.

0 comments on commit 319230f

Please sign in to comment.