jquense / expr

tiny util for getting and setting deep object props safely

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getter doesn't work when key begins with a number

corydeppen opened this issue · comments

Here's an example of an issue similar to #2 where the property name begins with a number and results in SyntaxError: Invalid or unexpected token.

My specific use case is working with the yup library to validate a schema. I have a series of properties that begin with numbers (thanks, Salesforce). So given path = '00N40000002S5U0', the result of calling expr() is (data.00N40000002S5U0), which clearly won't work. Before taking a crack at a PR, I'd just like to understand if it's reasonable to think this library should be able to build a valid expression for cases like this?