Skip to content

Can't Rule.test scalar data #9

Description

@aplowman

If we have a condition: cnd = Value.dtype.equal_to(str), we can test a datum like this: cnd.test('hello') -> bool. But if we have a rule with an empty path argument:

rule = Rule(path=[], condition=cnd)

...we cannot test a scalar datum in the same way:

rule.test('hello') # raises TypeError

...because we cast "hello" to a Data object, which expects a list or dict.

The workaround is to wrap the datum in a list and set the path to the first list element, like this:

rule = Rule(path=[0], condition=cnd)
rule.test(["hello"]) # success

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions