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

fix: changes made to the objectSchema #380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public class {{allName}} {
{%- if propName | isRequired(schema.required()) %}@NotNull{% endif %}
{%- if prop.minLength() or prop.maxLength() or prop.maxItems() or prop.minItems() %}@Size({% if prop.minLength() or prop.minItems() %}min = {{prop.minLength()}}{{prop.minItems()}}{% endif %}{% if prop.maxLength() or prop.maxItems() %}{% if prop.minLength() or prop.minItems() %},{% endif %}max = {{prop.maxLength()}}{{prop.maxItems()}}{% endif %}){% endif %}
{%- if prop.pattern() %}@Pattern(regexp="{{prop.pattern() | addBackSlashToPattern}}"){% endif %}
{%- if prop.minimum() %}@Min({{prop.minimum()}}){% endif %}{% if prop.exclusiveMinimum() %}@Min({{prop.exclusiveMinimum() + 1}}){% endif %}
{%- if prop.maximum() %}@Max({{prop.maximum()}}){% endif %}{% if prop.exclusiveMaximum() %}@Max({{prop.exclusiveMaximum() + 1}}){% endif %}
{%- if prop.minimum() %}@Min({{prop.minimum()}}){% endif %}{% if prop.exclusiveMinimum() %}@DecimalMin({{prop.exclusiveMinimum() + 1}}){% endif %}
{%- if prop.maximum() %}@Max({{prop.maximum()}}){% endif %}{% if prop.exclusiveMaximum() %}@DecimalMax({{prop.exclusiveMaximum() + 1}}){% endif %}
Comment on lines +149 to +150
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prop.minimum() means <=, the prop.maximum() means >= and exclusiveMinimum means just < and exclusiveMaximum is >.
So, change of exclusiveMinimum and exclusiveMaximum to @DecimalMin/@DecimalMax will lead to effect that all types (Integer, Long, Double e.t.c.) will have the @DecimalMin annotation.
The correct way to choose annotation between @Min and @DecimalMin, @Max and @DecimalMax would require to analyze value of {{propType}} in line below. Depending on {{propType}} the correct annotation should be set

public {{propType}} get{{className}}() {
return {{varName}};
}
Expand Down
Loading