VueGWT / vue-gwt

Vue.js Components/Custom Elements in Java with GWT. Developed at https://www.genmymodel.com.
https://vuegwt.github.io/vue-gwt/
MIT License
204 stars 46 forks source link

Documentation for @PropValidator #20

Closed slavap closed 6 years ago

slavap commented 6 years ago

It would be nice to mention in documentation that validator method should return boolean, i.e.

@PropValidator(propertyName = "size")
boolean sizeValidator(String value) {
    return "large".equals(value) || "small".equals(value);
}

Also declare propertyName as default, so it would be possible to use

@PropValidator("size") 
adrienbaron commented 6 years ago

Indeed, and the annotation processor should probably fail if it does't return a boolean. I add this as improvements. If you have time and want to try we also welcome external contributions ;).

slavap commented 6 years ago

@adrienbaron Not sure I can contribute currently with the code, but I have such plans for 2018.

adrienbaron commented 6 years ago

Ok I'll see to do this then πŸ˜‰

adrienbaron commented 6 years ago

I've just fixed 2 of the problems of this issue.

However regarding the default property to be able to use:

@PropValidator("size") 

This would force to rename propertyName to value. This would be a breaking change, and for consistency we would have to do that on the other annotation that take propertyName as parameter (like @Watch). I'm not sure the breaking change is worth it... But I would be glad to get your input on this.

slavap commented 6 years ago

@adrienbaron breaking change is not good of course, but in this case it makes sense IMO to do that. Existing code could be easily fixed, new code will be cleaner and shorter. Anyway, it’s up to you.

adrienbaron commented 6 years ago

Hum, I guess you are right. And better to do breaking changes early to improve the API. So I'll follow your recommendation and do that πŸ‘

slavap commented 6 years ago

@adrienbaron tested in beta6-snapshot, works, getting error on compile: [ERROR] Method variantValidator annotated with PropValidator must return a boolean. In VueComponent: com.axellience.vuegwtdemo.client.components.bootstrap.JqmButton