-
Notifications
You must be signed in to change notification settings - Fork 65
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 @pattern
support for constraint package
#3179
Closed
shafreenAnfar opened this issue
Jul 28, 2022
· 3 comments
· Fixed by ballerina-platform/module-ballerina-constraint#29
Closed
Add @pattern
support for constraint package
#3179
shafreenAnfar opened this issue
Jul 28, 2022
· 3 comments
· Fixed by ballerina-platform/module-ballerina-constraint#29
Labels
Milestone
Comments
shafreenAnfar
added
Type/Improvement
Team/PCM
Protocol connector packages related issues
module/constraint
labels
Jul 28, 2022
shafreenAnfar
changed the title
Add @pattern support for constraint package
Add Aug 1, 2022
@pattern
support for constraint package
Required support issue : ballerina-platform/ballerina-spec#130 |
The regex support is now given in the language : https://ballerina.io/spec/lang/master/#lang.regexp Example usage for pattern matching : import ballerina/io;
public function main() {
// Defining a regular expression
string:RegExp regExp = re `[0-9]*`;
string testString1 = "0123456789";
string testString2 = "012345ab";
if regExp.isFullMatch(testString1) {
io:println("Test string 1 is a full match");
} else {
io:println("Test string 1 is not a full match");
}
if regExp.isFullMatch(testString2) {
io:println("Test string 2 is a full match");
} else {
io:println("Test string 2 is not a full match");
}
} Applying pattern constraint using the constraint module : import ballerina/constraint;
string:RegExp regExp = re `[^0-9]*`;
@constraint:String {
length: 10,
pattern: regExp
}
type PhoneNumber string;
type User record {|
string name;
int age;
@constraint:String {
pattern: re `([0-9]{9}[v|V]|[0-9]{12})`
}
string nic;
string address;
PhoneNumber contactNumber;
|}; |
Found a blocker in the runtime : ballerina-platform/ballerina-lang#38336 |
Merged
5 tasks
TharmiganK
closed this as completed
in
ballerina-platform/module-ballerina-constraint#29
Jan 17, 2023
github-project-automation
bot
moved this from PR Sent
to Done
in Ballerina Team Main Board
Jan 17, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
This was not implemented due to no support for Regex in the language.
#2850
The text was updated successfully, but these errors were encountered: