Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Input validation of options types oddly specific #897

Open
dmeehan1968 opened this issue Oct 22, 2023 · 0 comments
Open

bug: Input validation of options types oddly specific #897

dmeehan1968 opened this issue Oct 22, 2023 · 0 comments

Comments

@dmeehan1968
Copy link

Docs: https://github.com/Stedi/ts2asl/blob/main/examples/input-validation.md#check-argument-type-provide-default

When the input type might be optional/undefined, the specific syntax required seems to be oddly specific (as per the documentation, it seems it only copes with the conditional test being not equal to the expected input type.

I've tried alternates such as:

  • Truthy: if (!input.property) {...
  • Test against undefined: if (input.property === undefined) {...

If the documented syntax isn't used, I get the error:

An error occurred while executing the state 'If (input.property === ...' (entered at the event id #4). Invalid path '$.vars.property': The choice state's condition path references an invalid value.

A test against the type seems too narrow, but I suspect its triggered by the input type being specified as a union including undefined, whether as an optional or specifically with undefined:

interface MyType {
  maybeProperty: string | undefined
  optionalProperty?: string
}

In either case, it seems that it should recognise the presence of the property.

I can think of cases where the step function is consuming multiple sources, and wanting to branch on the presence of a discriminator, which might be a property with a certain value, type, or union of mutually exclusive types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant