[ https://issues.apache.org/jira/browse/SLING-3679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14041036#comment-14041036 ]
Justin Edelson commented on SLING-3679: --------------------------------------- Sorry, I'm still not understanding. If a field is not required, you should annotate it with @Optional. If a field is not required, but needs extra validation, you can do that in the @PostConstruct method and throw an (unchecked) exception. > Required fields validation > -------------------------- > > Key: SLING-3679 > URL: https://issues.apache.org/jira/browse/SLING-3679 > Project: Sling > Issue Type: Improvement > Components: Extensions > Affects Versions: Sling Models Implementation 1.0.4 > Reporter: Krystian Panek > Labels: models > > Currently if some field cannot be injected (and it is not annotated with > @Optional), model adapter factory returns null. However fact that some field > has null and all other are properly injected is acceptable in my context. > Proposal: > * model adapter factory does not return null if not all required fields are > injected, > * result of requirement validation is serviced as for example: > ** injecting it to some extra annotated field: @Valid boolean valid; (with > default false), > ** passing bool parameter in @PostConstruct callback, for example 'valid' > (true if all required field are injected, false otherwise), > * behave current behavior, new available only with extra model class > annotation, for example @NotNull . -- This message was sent by Atlassian JIRA (v6.2#6252)