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

minInclusive on a type xs:gYearMonth #8

Closed
kalgon opened this issue Apr 4, 2013 · 7 comments
Closed

minInclusive on a type xs:gYearMonth #8

kalgon opened this issue Apr 4, 2013 · 7 comments

Comments

@kalgon
Copy link

kalgon commented Apr 4, 2013

Hi,

I have a schema with the following type:

<xs:restriction base="xs:gYearMonth">
  <xs:minInclusive value="1911-01"/>
  <xs:pattern value="\d{4}-\d{2}"/>
</xs:restriction>

this generates an annotation @DecimalMin("1911-01") which will throw a NumberFormatException because 1911-01 cannot be converted to a BigDecimal value although "1911-01" is a legal minInclusive value for xs:gYearMonth (see http://books.xmlschemata.org/relaxng/ch19-77135.html).

What would be the solution?

  • have a custom annotation for this case?
  • not adding the @DecimalMin annotation when the value is not a BigDecimal?

Thanks,

Xavier

@krasa
Copy link
Owner

krasa commented Apr 4, 2013

Hi,
As far as I know, bean validations supports only @past and @future, so @DecimalMin should not be generated. I will fix that. (ETA 10 hours)

It would be nice to implement some custom annotation. Pull requests are welcomed :)

@kalgon
Copy link
Author

kalgon commented Apr 4, 2013

I think the way of the custom annotation is inevitable as I stumbled upon another problem with xs:choice:

<xs:complexType name="DrinkType">
  <xs:sequence>
    <xs:choice>
      <xs:element ref="Tea"/>
      <xs:element ref="Coffee"/>
    </xs:choice>
  </xs:sequence>
</xs:complexType>

which generates:

public class DrinkType {
  @NotNull Tea tea;
  @NotNull Coffee coffee;
}

I think something like this would be better:

@Choice({"tea", "coffee"})
public class DrinkType {
  Tea tea;
  Coffee coffee;
}

Xavier

@krasa
Copy link
Owner

krasa commented Apr 4, 2013

Date is fixed in 0.5-SNAPSHOT

@krasa
Copy link
Owner

krasa commented Apr 4, 2013

Fixing the choice will be very hard.

krasa added a commit that referenced this issue Apr 4, 2013
@krasa
Copy link
Owner

krasa commented May 1, 2013

so @NotNull at choices is fixed.

@hestad
Copy link

hestad commented Sep 15, 2013

Do you see any solution on the @Choice-issue? Btw, I think this issue should have been split into two issues.

@krasa
Copy link
Owner

krasa commented Sep 15, 2013

Well I do not have solution, but I think it should be possible. I have even seen some ugly way how to find out what is defined as choice....
Contributions are welcomed.

And you are right, I will split it.

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

No branches or pull requests

3 participants