Angular - Spring support - request validation



I'm starting with an angular+spring project. I've been struggling with an error which occurs quite often - - a difference between a structure sent from front-end and a request class in a back-end. Namely:

in front end:<any>('http://localhost:8080/login', {username: username, password: password}

in the back end:

public class LoginRequest {
@Getter @Setter private String login;
@Getter @Setter private String password;

....aand here it is, login=null. Is there a way to validate the typescript code against java model? This is really irritating for a developer which is used to static/compiler validation. I have a project which contains two modules - one for angular and one for spring(boot).



评论操作 固定链接

I don't think IntelliJ IDEA has such a feature.

评论操作 固定链接

note - I wouldn't mind if I needed to add some annotations or use a proxy pattern or whatever

Direct validation would be hard indeed, but one could define schema and somehow assign it to both typescript and java code, like here: