Skip to content
New issue

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

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

Already on GitHub? # to your account

Constraint validation does not work for readonly records #3742

Closed
dilanSachi opened this issue Dec 1, 2022 · 0 comments · Fixed by ballerina-platform/module-ballerina-constraint#46
Assignees
Labels
module/constraint Points/1 Team/PCM Protocol connector packages related issues Type/Improvement
Milestone

Comments

@dilanSachi
Copy link
Contributor

Description:
Check the following sample.

import ballerina/io;
import ballerina/constraint;

type Album readonly & record {|
    @constraint:String {
        maxLength: 5,
        minLength: 1
    }
    string title;
    string artist;
|};

public function main() returns error? {
    Album a = {
        artist: "test",
        title: "testss"
    };
    Album validAlbum = check constraint:validate(a);
    io:println(validAlbum);
}

Ideally this should return an error. Instead it prints the value successfully.

{"title":"testss","artist":"test"}

constraint- v1.0.1

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
module/constraint Points/1 Team/PCM Protocol connector packages related issues Type/Improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants