Skip to content

Weird issue with 0.13.0: multiple tuple item type support #44

Closed
@benderTheCrime

Description

@benderTheCrime

In an ill advised effort to use the new multitype tuple feature to allow any type in an object in any position of an Array, I think I've uncovered a weird bug:

here is my schema for an Array property "args":

        args: {
            items: [
                {
                    type: 'object',
                    patternProperties: {
                        '.*': {
                            type: 'string',
                        },
                    },
                },
                {
                    type: 'object',
                    patternProperties: {
                        '.*': {
                            type: 'number',
                        },
                    },
                },
                {
                    type: 'object',
                    patternProperties: {
                        '.*': {
                            type: 'null',
                        },
                    },
                },
                {
                    type: 'object',
                    patternProperties: {
                        '.*': {
                            type: 'boolean',
                        },
                    },
                },
            ],
            type: 'array',
        },

and then here is my object:

const obj = {
    args: [
        'foo', 
        {
            foo: 1,
            bar: 'foo',
        }
     ],
};

This is the result:

{"args":[,{"foo":"1","bar":"foo"}{"foo":1,"bar":null}{"foo":null,"bar":null}{"foo":true,"bar":true}]}

I was just attempting to use this for which it wasn't intended, but at the same time, this returns an invalid JSON string, which I don't think is desirable behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions