jokade / angulate2

Scala.js bindings for Angular
MIT License
87 stars 15 forks source link

Validate inputs at compile time #22

Open gregghz opened 8 years ago

gregghz commented 8 years ago

I recently had an issue where is set an input equal to "the-hero". The @Component macro lets this through, but angular throws at runtime since that's not a valid JavaScript identifier. I think it would be fairly simple to validate inputs at compile time inside the macro. You would have to account for the "a:b" syntax of inputs as well. I don't know off the top of my head what the js identifier regex is, but it should be fairly simple. For performance, you could create a pretty simple manual parser as well but for simplicity's sake a simple regex is probably fine.