lsp4jakarta icon indicating copy to clipboard operation
lsp4jakarta copied to clipboard

Jakarta Bean Validation Size and NotEmpty annotation diagnostics

Open rezaakv opened this issue 4 years ago • 4 comments

Add diagnostics for these constraints to ensure they are annotated on the supported types.

The main problem is that these annotations work on field types of Collections, Arrays and Map, which should be resolved (before using them to check against the allowed types below) and also the type could be any custom subtype of these interfaces including user made ones.

@NotEmpty: Supported types are:

  • CharSequence (length of character sequence is evaluated)
  • Collection (collection size is evaluated)
  • Map (map size is evaluated)
  • Array (array length is evaluated)

@Size: Supported types are:

  • CharSequence (length of character sequence is evaluated)
  • Collection (collection size is evaluated)
  • Map (map size is evaluated)
  • Array (array length is evaluated)

rezaakv avatar Nov 29 '20 02:11 rezaakv

Hello everyone, Can assign to me?

mcruzdev avatar Feb 05 '21 17:02 mcruzdev

Hi everyone, @kathrynkodama

How can I get a type of IField?

By example:

@Size
private String value;

@Size
private Map map;

I want to get the FQN of filed type (map and value) Because I will need to verify if the type is one java.util.Map or java.util.List etc Is there an example or documentation for help me?

If you have other approach, will be appreciate, thank you 😁

mcruzdev avatar Feb 18 '21 01:02 mcruzdev

@mcruzdev you can use IField https://www.ibm.com/support/knowledgecenter/en/SSUFAU_2.0.0/org.eclipse.jdt.doc.isv-3.14.100/reference/api/org/eclipse/jdt/core/class-use/IField.html.

See PersistenceMapKeyDiagnosticsCollector for an example of a diagnostic appearing on a field.

kathrynkodama avatar Feb 19 '21 15:02 kathrynkodama

This should be added for Jakarta EE 11

mswatosh avatar Jun 06 '24 13:06 mswatosh