Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.
This repository was archived by the owner on May 19, 2025. It is now read-only.

"Type[] | Null" produces incorrect rules #118

@mm-gmbd

Description

@mm-gmbd

The following Bolt rules:

type Something {
  A: Boolean,
  B: Number[] | Null
}

path /path is Something {
  read() = true;
}

produce the following rules json:

{
  "rules": {
    "path": {
      ".validate": "newData.hasChildren(['A'])",
      "A": {
        ".validate": "newData.isBoolean()"
      },
      "B": {
        "$key1": {
          ".validate": "newData.isNumber()"
        },
        ".validate": "newData.val() == null"
      },
      "$other": {
        ".validate": "false"
      },
      ".read": "true"
    }
  }
}

Notice the rules for B. It correctly produces the map rule ensuring that all wildcarded children are numbers, but it also produces a rule for B itself, validation that newData.val() == null. This precludes me from being able to write anything at /path/B!

I think the desired behavior would be, when encountered with an Type[] | Null, it would not produce any validation at the level of Type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions