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

Regular expressions do not work with flags #302

Closed
jeromesimeon opened this issue Aug 4, 2021 · 0 comments · Fixed by #303
Closed

Regular expressions do not work with flags #302

jeromesimeon opened this issue Aug 4, 2021 · 0 comments · Fixed by #303
Assignees
Labels

Comments

@jeromesimeon
Copy link
Member

Bug Report 🐛

Regular expressions with flags e.g., /^[a-zA-Z0-1]*^/u do not work.

Expected Behavior

Regular expressions should work with flags.

Current Behavior

With the given CTO:

namespace org.test

concept Person {
	o String name regex=/^[a-zA-Z][a-zA-Z0-9]*$/u
	o Double age
}

And input data:

{
    "$class": "org.test.Person",
    "name": "John",
    "age": 33
}

The validation fails:

zsh-5.8$ concerto validate --model test.cto --input person.json
7:56:56 AM - INFO: Input is invalid
7:56:56 AM - ERROR: Validator error for field undefined org.test.Person.name: Value + 'John' failed to match validation regex: /^[a-zA-Z][a-zA-Z0-9]*$\//
Error: Validator error for field undefined org.test.Person.name: Value + 'John' failed to match validation regex: /^[a-zA-Z][a-zA-Z0-9]*$\//
    at StringValidator.reportError (/usr/local/lib/node_modules/@accordproject/concerto-cli/node_modules/@accordproject/concerto-core/lib/introspect/validator.js:44:15)
    at StringValidator.validate (/usr/local/lib/node_modules/@accordproject/concerto-cli/node_modules/@accordproject/concerto-core/lib/introspect/stringvalidator.js:56:22)
    at ResourceValidator.checkItem (/usr/local/lib/node_modules/@accordproject/concerto-cli/node_modules/@accordproject/concerto-core/lib/serializer/resourcevalidator.js:327:42)
    at ResourceValidator.visitField (/usr/local/lib/node_modules/@accordproject/concerto-cli/node_modules/@accordproject/concerto-core/lib/serializer/resourcevalidator.js:221:22)
    at ResourceValidator.visit (/usr/local/lib/node_modules/@accordproject/concerto-cli/node_modules/@accordproject/concerto-core/lib/serializer/resourcevalidator.js:77:25)
    at Field.accept (/usr/local/lib/node_modules/@accordproject/concerto-cli/node_modules/@accordproject/concerto-core/lib/introspect/decorated.js:65:24)
    at ResourceValidator.visitClassDeclaration (/usr/local/lib/node_modules/@accordproject/concerto-cli/node_modules/@accordproject/concerto-core/lib/serializer/resourcevalidator.js:174:26)
    at ResourceValidator.visit (/usr/local/lib/node_modules/@accordproject/concerto-cli/node_modules/@accordproject/concerto-core/lib/serializer/resourcevalidator.js:73:25)
    at ConceptDeclaration.accept (/usr/local/lib/node_modules/@accordproject/concerto-cli/node_modules/@accordproject/concerto-core/lib/introspect/decorated.js:65:24)
    at ValidatedResource.validate (/usr/local/lib/node_modules/@accordproject/concerto-cli/node_modules/@accordproject/concerto-core/lib/model/validatedresource.js:125:26)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant