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

feat: support declared type as array for jsonSchema #1590

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yzaouzaou
Copy link

When using Jsr303 annotation, to get our objects fileds checked for constraints, we have to annotate them with @Valid, this annotation is added on fileds that aren't premetives (or objects représenting premitives like : Integer) to recursively check constraints.
Until now, to annotate a field with this annotation, we check for it's type weither it's "object" or "array". Since the specification of jsonSchema seems to accept a string or an array of strings, when we use an array of strings the annotation @Valid is not added to the field, thus, the field is not checked for constraints.

for example, in the current version, if we use this jsonShema (which is valid according to specification of jsonschema)

{
  "type": "object",
  "properties": {
    "myFiled": {
      "type": ["object", "null"],
      "properties": {
        "childprimitivefield": {
          "type": "string",
          "maxLength": 5
        }
      }
    }
  }
}

The filed myField will not have the annotation @Valid and it's objects won't be validated.

Some links :

PS :

For tests, i have just changed existing tests, please let me know if it's better to duplicate existing tests to cover this new feature even if it's the same as existing one 😃.

@yzaouzaou yzaouzaou force-pushed the feature/fix_application_of_valid_annotation_when_using_jsr303 branch from af6fb66 to 0cad75d Compare March 2, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant