You can use component.valid inside the style or styleClass attribute of your inputText:
<h:inputText value="#{cc.attrs.value}" styleClass="#{component.valid ? '' : 'error'}" />
However, this will not work in your div , as it is not a jsf component. You can try component binding (from theory, not tested):
<div class="#{myComponent.valid ? '' : 'error'}"> <h:inputText id="input" value="#{cc.attrs.value}" binding="#{myComponent}"> <cc:insertChildren /> </h:inputText> </div>
source share