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

Passing the typedesc as a param to the constraint() method returns () in success case #3107

Closed
chamil321 opened this issue Jul 12, 2022 · 2 comments · Fixed by ballerina-platform/module-ballerina-constraint#3
Assignees
Labels
module/constraint Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug

Comments

@chamil321
Copy link
Contributor

chamil321 commented Jul 12, 2022

Description:
$subject. In HTTP, the expected type is coming from an HTTP API, hence constraint method cannot infer the expected type from the LHS. So when the expected type was passed as the second param, the validation happens and return ()

Steps to reproduce:

isolated function performDataValidation(anydata payload, typedesc<anydata> targetType) returns anydata|ClientError {
    anydata|error validPayload = constraint:validate(payload, targetType);
    if validPayload is error {
        return error PayloadValidationClientError("payload validation failed: " + validPayload.message(), validPayload);
    } else {
        return validPayload; // this value is ()
    }
}

Affected Versions:
1.0.0-20220711-153400-5cab109

@chamil321 chamil321 changed the title Passing the typedesc as the second param to the constraint method returns () Passing the typedesc as a param to the constraint() method returns () in success case Jul 12, 2022
@dilanSachi
Copy link
Contributor

Noticed this even for a case as follows.

StringConstraintConsumerRecord|error result = constraint:validate(payload);

@github-actions
Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/constraint Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants