teleporthq/teleport-code-generators

Improve validations for checking `name` on `elementNode`

JayaKrishnaNamburu opened this issue ยท 4 comments

https://github.com/teleporthq/teleport-code-generators/blob/development/packages/teleport-uidl-validator/src/decoders/utils.ts#L472

Right now, here we check if the UIDL's name is valid. But when we pass a empty string the validation breaks. name field is not mandatory, but don't throw an error. Instead just ignore the name

https://repl.teleporthq.io/?uidlLink=02853c0e-b6dd-45fa-b9e5-74bd6f3d7890&flavor=React&style=CSS-Modules

I want to work on this issue, can you assign this to me?

Thank you @chavda-bhavik, please let me know if you have any doubts ๐Ÿ˜„

@JayaKrishnaNamburu can you say where can I test things. Like if I want to check if component validation and decoding is happening or not from UIDL? In projects/teleport-test?

And we need to resolve this empty name string issue for the root node or child nodes that stay in node: {...}, or for both?

So, we are doing validation of names in three different places isValidComponentName, isValidFileName, isValidElementName, i am looking to improve these three checks. Since all 3 will have the similar issue. But currently the main focus in on isValidElementName since fileName and Component Name have fallbacks. You can use packages/teleport-test to test this out, or by writing a new test case under
teleporthq/teleport-code-generators/packages/teleport-uidl-validator/__tests__/validator. With the json i shared using repl.

Please let me know if you need any further help. I can setup a branch to work with this in the fork ๐Ÿ˜„