Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using string.length with empty string: "Invalid < expression: Left and right sides types are differents" #125

Closed
SamyPesse opened this issue Jul 30, 2017 · 4 comments
Labels
Milestone

Comments

@SamyPesse
Copy link

When the rules contain something like:

"bio": {
  ".validate": "newData.isString() && newData.val().length < 100"
}

And testing with a write with "bio": "", targaryen throws an error:

Error: newData.val().length < 100: Invalid < expression: Left and right sides types are differents.

If I test by having a non-empty string for bio, it works.

@dinoboff
Copy link
Collaborator

dinoboff commented Aug 2, 2017

I will test that and try to fix it this weekend, unless someone tackles it first.

@dinoboff
Copy link
Collaborator

dinoboff commented Aug 2, 2017

Here is the test:

./bin/targaryen-specs -a '{"tests": [{
>   "rule": "root.child(\"foo\").val().length < 100",
>   "data": {"foo": ""}
> }]}'

Output:

{ Error: Targaryen and Firebase evaluation of "root.child("foo").val().length < 100" diverges.
spec:
   RuleSpec {
     rule: 'root.child("foo").val().length < 100',
     user: 'unauth',
     wildchildren: undefined,
     data: { foo: '' },
     isValid: true,
     failAtRuntime: false,
     evaluateTo: true },
  targaryen: { isValid: true, failAtRuntime: true, evaluateTo: undefined } }

dinoboff added a commit to dinoboff/targaryen that referenced this issue Aug 2, 2017
@dinoboff dinoboff added the bug label Aug 2, 2017
@dinoboff dinoboff added this to the 3.0.2 milestone Aug 2, 2017
dinoboff added a commit that referenced this issue Aug 3, 2017
@dinoboff
Copy link
Collaborator

dinoboff commented Aug 3, 2017

@SamyPesse Thanks finding the bug and reporting it. I will release the 3.0.2 this weekend.

@dinoboff
Copy link
Collaborator

@SamyPesse Released (sorry for the delay).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants