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 to overwrite default error message #79

Merged

Conversation

TharmiganK
Copy link
Contributor

@TharmiganK TharmiganK commented Jun 1, 2023

Purpose

$Subject

Fixes : ballerina-platform/ballerina-library#3211

Examples

@constraint:String {
    minLength : {
        value : 5,
        message : "UserName should have atleast 5 characters"
    },
    maxLength : {
        value : 12,
        message : "UserName can have atmost 12 characters"
    },
    pattern : {
        value : re `^[a-zA-Z0-9]+$`,
        message : "Only alpha numeric characters are allowed in UserName"
    }
}
type UserName string;

@constraint:Date {
    option : {
        value : constraint:PAST,
        message : "Date of Birth should be in the past"
    },
    message : "Invalid date found for Date of Birth"
}
type DateOfBirth time:Date;

Checklist

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

@codecov
Copy link

codecov bot commented Jun 1, 2023

Codecov Report

Patch coverage: 90.74% and project coverage change: +0.97 🎉

Comparison is base (6be4961) 87.46% compared to head (7fa9fda) 88.44%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #79      +/-   ##
============================================
+ Coverage     87.46%   88.44%   +0.97%     
- Complexity      175      288     +113     
============================================
  Files            20       37      +17     
  Lines           367      649     +282     
  Branches         65      114      +49     
============================================
+ Hits            321      574     +253     
- Misses           29       50      +21     
- Partials         17       25       +8     
Impacted Files Coverage Δ
...allerina/stdlib/constraint/compiler/Constants.java 0.00% <ø> (ø)
ballerina/constraint.bal 50.00% <33.33%> (-38.89%) ⬇️
...stdlib/constraint/annotations/TypeAnnotations.java 69.76% <75.00%> (ø)
...va/io/ballerina/stdlib/constraint/Constraints.java 73.13% <90.00%> (ø)
...onstraint/validators/interfaces/DateValidator.java 95.00% <90.00%> (+8.33%) ⬆️
...llerina/stdlib/constraint/ConstraintErrorInfo.java 90.90% <90.90%> (ø)
...traint/compiler/ConstraintCompilerPluginUtils.java 96.20% <95.83%> (ø)
...java/io/ballerina/stdlib/constraint/Constants.java 83.33% <100.00%> (+8.33%) ⬆️
...ava/io/ballerina/stdlib/constraint/ErrorUtils.java 92.00% <100.00%> (+13.05%) ⬆️
...ib/constraint/annotations/AbstractAnnotations.java 100.00% <100.00%> (ø)
... and 10 more

... and 14 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.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@TharmiganK
Copy link
Contributor Author

Reverted the changelog and spec update because there is this issue in the tooling support which cannot be merged for update 7. So planned to market this in the next release.

@TharmiganK TharmiganK added the Skip GraalVM Check This will skip the GraalVM compatibility check label Jun 14, 2023
@TharmiganK TharmiganK merged commit 82b8d9f into ballerina-platform:main Jun 14, 2023
@TharmiganK TharmiganK deleted the constraint-error-message branch June 14, 2023 08:42
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
2 participants