Skip to content

Commit

Permalink
Add dot_notation validator
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanpro committed Sep 30, 2024
1 parent e7e83bc commit 020469b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/components/mixins/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,28 @@ export default {
},
"Must have a value between :between"
);

// Update screen builder's tests/e2e/specs/Builder.spec.js when changing this
Validator.register(
"dot_notation",
(path) => {
// Split the string by dots
const keys = path.split('.');

// Regular expression for valid keys: start with a letter, followed by letters, numbers, or underscores
const validKey = /^[a-zA-Z][a-zA-Z0-9_]*$/;

// Check each key for validity
for (let key of keys) {
if (!validKey.test(key)) {
return false;
}
}

return true;
},
"Invalid variable name",
);
}
}
};

0 comments on commit 020469b

Please sign in to comment.