You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently found this package and started implementing it as a way to combine resources, requests, validation rules and more into a single class. I have a pretty large and complex data structure with a lot of conditional logic.
I have many cases where the available enum options differs depending on another value in the same data class or possibly even in the parent.
enum CustomEnum: string {
case case1 = 'case_1';
case case2 = 'case_2';
}
enum CustomEnum2: string {
case case3 = 'case_3';
case case4 = 'case_4';
}
class Parent extends Data {
publicfunction__construct(
publicstring$uid,
publicstring$type,
publicCustomEnum|CustomEnum2$prop,
publicChild$childValues,
) {
}
}
class Child extends Data {
publicfunction__construct(
publicint$val1,
publicint$val2.
publicint$val3
) {
}
}
Based on the simplified example above I need the following logic:
$parent->prop can be anything in CustomEnum if $parent->type is 'X' but must be anything in CustomEnum2 if $parent->type is 'Y'
$childValues->val3 is required if $parent->type is 'X' but shouldn't exist if $parent->type is 'Y'
Another more advanced example is that the available enum options can differ based on multiple other input values.
I would also like to set this up in a way that allows the TypeScript generator to understand the conditional logic that is applied if possible
Is it possible to achieve this logic without too much custom code? How would I go about achieving this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I recently found this package and started implementing it as a way to combine resources, requests, validation rules and more into a single class. I have a pretty large and complex data structure with a lot of conditional logic.
I have many cases where the available enum options differs depending on another value in the same data class or possibly even in the parent.
Based on the simplified example above I need the following logic:
Another more advanced example is that the available enum options can differ based on multiple other input values.
I would also like to set this up in a way that allows the TypeScript generator to understand the conditional logic that is applied if possible
Is it possible to achieve this logic without too much custom code? How would I go about achieving this?
Beta Was this translation helpful? Give feedback.
All reactions