Skip to content

Validation does not work as expected when required files are based on if..then..else.. conditions #95

@antmendoza

Description

@antmendoza

I suppose that this is an issue in the library we are using to validate object, (I will check the open issues tomorrow)

What happened:

foreachstateValidator is not working well when required files are based on if..then..else.. conditions

What you expected to happen:

According to the specification, foreachstate with
"name",
"type",
"inputCollection",
"iterationParam",
"actions",
"end"

is a valid object

How to reproduce it:

The code below

import {actionBuilder, foreachstateBuilder, produceeventdefBuilder} from '../../src';


fdescribe("", () => {
	
	it('should xxx', function () {
		
		const object = foreachstateBuilder()
			.name("ProvisionOrdersState")
			.inputCollection("${ .orders }")
			.iterationParam("singleorder")
			.outputCollection("${ .provisionedOrders }")
			.actions([
				actionBuilder()
					.functionRef({
							refName: "provisionOrderFunction",
							arguments: {
								"order": "${ .singleorder }",
							},
						},
					)
					.build(),
			])
			.end({
					produceEvents: ([
						produceeventdefBuilder()
							.eventRef("provisioningCompleteEvent")
							.data("${ .provisionedOrders }")
							.build(),
					]),
				},
			)
			.build()
		
		
		expect(object.name).toEqual("ProvisionOrdersState")
	});
	
	
})


that generated the following object (a valid one)

{
    "name": "ProvisionOrdersState",
    "inputCollection": "${ .orders }",
    "iterationParam": "singleorder",
    "outputCollection": "${ .provisionedOrders }",
    "actions": [
        {
            "functionRef": {
                "refName": "provisionOrderFunction",
                "arguments": {
                    "order": "${ .singleorder }"
                }
            }
        }
    ],
    "end": {
        "produceEvents": [
            {
                "eventRef": "provisioningCompleteEvent",
                "data": "${ .provisionedOrders }"
            }
        ]
    },
    "type": "foreach"
}

fails with the following error

[
  {
    instancePath: '',
    schemaPath: '#/then/required',
    keyword: 'required',
    params: { missingProperty: 'workflowId' },
    message: "must have required property 'workflowId'"
  }
]
F

Failures:
1) should xxx
  Message:
    Error: Foreachstate is invalid: must have required property 'workflowId'


Anything else we need to know?:

adding to the object construction
.usedForCompensation(false)
works fine.

Environment:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions