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

Add support for providing constraint failure message #77

Closed

Conversation

TharmiganK
Copy link
Contributor

Purpose

$Subject

Fixes : ballerina-platform/ballerina-library#3211

Examples

type User record {
    @constraint:String {
        minLength: 1,
        maxLength: 10,
        message: "User name should not exceed 10 characters"
    }
    string userName;
    @constraint:Int {
        minValue: 18,
        message: "User should be atleast 18 years old"
    }
    int age;
};

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests
  • Updated the spec
  • Checked native-image compatibility

@TharmiganK TharmiganK added the Skip GraalVM Check This will skip the GraalVM compatibility check label May 15, 2023
@codecov
Copy link

codecov bot commented May 15, 2023

Codecov Report

Patch coverage: 74.17% and project coverage change: -3.56 ⚠️

Comparison is base (28cdb1d) 85.34% compared to head (f9d476b) 81.78%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #77      +/-   ##
============================================
- Coverage     85.34%   81.78%   -3.56%     
- Complexity      142      233      +91     
============================================
  Files            18       34      +16     
  Lines           307      571     +264     
  Branches         56      104      +48     
============================================
+ Hits            262      467     +205     
- Misses           28       67      +39     
- Partials         17       37      +20     
Impacted Files Coverage Δ
...java/io/ballerina/stdlib/constraint/Constants.java 0.00% <ø> (ø)
...llerina/stdlib/constraint/ConstraintErrorInfo.java 50.00% <50.00%> (ø)
...va/io/ballerina/stdlib/constraint/Constraints.java 62.02% <55.55%> (-11.11%) ⬇️
...ava/io/ballerina/stdlib/constraint/ErrorUtils.java 72.58% <72.34%> (-6.37%) ⬇️
...stdlib/constraint/annotations/TypeAnnotations.java 69.76% <75.00%> (ø)
...onstraint/validators/FloatConstraintValidator.java 88.23% <80.00%> (-11.77%) ⬇️
.../constraint/validators/IntConstraintValidator.java 88.23% <80.00%> (-11.77%) ⬇️
...nstraint/validators/NumberConstraintValidator.java 88.23% <80.00%> (-11.77%) ⬇️
...onstraint/validators/ArrayConstraintValidator.java 88.23% <81.81%> (-11.77%) ⬇️
...nstraint/validators/StringConstraintValidator.java 90.00% <84.61%> (-10.00%) ⬇️
... and 6 more

... and 15 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@TharmiganK
Copy link
Contributor Author

Closing this as we have decided on a different proposal

@TharmiganK TharmiganK closed this May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip GraalVM Check This will skip the GraalVM compatibility check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make error message more context descriptive by allowing custom messages
1 participant