question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using "Any" generates incorrect rules

See original GitHub issue

Consider the following setup:

type MyType {
  num: Number,
  str: String,
  any: Any
}

path / {
  read()  = true;
  write() = true;
}

path /path is MyType {
  read() = true();
  write() = true();
}

The third property of MyType is defined as type Any, so I would expect that, at path in the rules, it would ensure that any was included in a newData.hasChildren([]) statement, and then the specific .validate rule would check to ensure that it wasn’t null. However, the following rules are generated:

{
  "rules": {
    "path": {
      ".validate": "newData.hasChildren(['num', 'str', 'any'])",
      "num": {
        ".validate": "newData.isNumber()"
      },
      "str": {
        ".validate": "newData.isString()"
      },
      "$other": {
        ".validate": "false"
      },
      ".read": "true()",
      ".write": "true()"
    }
  }
}

Notice the complete lack of a .validate rule for any, even though the parent .validate includes it in .hasChildren(). Because this is left out, the $other wildcard .validate: false rule breaks the rule generation!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mm-gmbdcommented, Apr 21, 2016

Hey @mckoss - any update on this one? I just revisited some rules, used Any as a type, and fell into the same pitfall. Looking at the docs indicated that I wasn’t doing anything wrong, but I had to come here to remember the issue - maybe the docs could be updated in the meantime (i.e. next to “Any” there could be a warning that says not to use it, or it could be removed entirely for now)?

1reaction
pandaiolocommented, Jul 5, 2016

Hi

Also bumped into this issue. I use this workaround:

// Use this instead of type `Any`
type Anything {
    validate() {
        this.isString() || this.isNumber() || this.isBoolean() || this.hasChildren()
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix Excel Conditional Formatting Problem Extra Rules
Fix Excel conditional formatting problems when extra rules are automatically created. How to remove duplicate rules and prevent them from ...
Read more >
network_policy_controller.go generates incorrect iptables rules
network_policy_controller.go generates KUBE-ROUTER-INPUT filter rules with a -j RETURN when accepting traffic. This results in a return to ...
Read more >
Action rule editing errors and warnings - IBM
Rule Designer searches for problems when you edit an action rule. Errors and warnings are displayed in the Problems view.
Read more >
kie - Why Drools is executing incorrect rules when multiple ...
Show activity on this post. Drools seems to give incorrect results when multiple processes are run in parallel and in each process, a...
Read more >
Restrict data input by using validation rules - Microsoft Support
Create a record validation rule​​ On the Fields tab, in the Field Validation group, click Validation, and then click Record Validation Rule. Use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found