@Test public void validation() throws Exception { assertTrue(subject.validation(new Validation("ip", "fe80:0:0:0:0:0:c0a8:11"))); assertTrue(subject.validation(new Validation("ip", "192.168.2.255"))); assertFalse(subject.validation(new Validation("ip", "nope"))); }
@PostMapping({"/internal/validate", "/protected/validate"}) public boolean validation(@Validated @RequestBody Validation validation) { return !validators.computeIfAbsent(validation.getType(), key -> { throw new IllegalArgumentException(String.format("No validation defined for %s", key)); }).validate(validation.getValue()).isPresent(); }
ValidationController implements IPAddressProvider { @PostMapping({"/internal/validate", "/protected/validate"}) public boolean validation(@Validated @RequestBody Validation validation) { return !validators.computeIfAbsent(validation.getType(), key -> { throw new IllegalArgumentException(String.format("No validation defined for %s", key)); }).validate(validation.getValue()).isPresent(); } }
ValidationController implements IPAddressProvider { @PostMapping({"/internal/validate", "/protected/validate"}) public boolean validation(@Validated @RequestBody Validation validation) { return !validators.computeIfAbsent(validation.getType(), key -> { throw new IllegalArgumentException(String.format("No validation defined for %s", key)); }).validate(validation.getValue()).isPresent(); } ValidationController(); }
ValidationController implements IPAddressProvider { @PostMapping({"/internal/validate", "/protected/validate"}) public boolean validation(@Validated @RequestBody Validation validation) { return !validators.computeIfAbsent(validation.getType(), key -> { throw new IllegalArgumentException(String.format("No validation defined for %s", key)); }).validate(validation.getValue()).isPresent(); } ValidationController(); @PostMapping({"/internal/validate", "/protected/validate"}) boolean validation(@Validated @RequestBody Validation validation); @GetMapping({"/internal/ipinfo", "/protected/ipinfo"}) IPInfo ipInfo(@RequestParam String ipAddress,
                         @RequestParam(required = false) Integer networkPrefix); }
ValidationController implements IPAddressProvider { @PostMapping({"/internal/validate", "/protected/validate"}) public boolean validation(@Validated @RequestBody Validation validation) { return !validators.computeIfAbsent(validation.getType(), key -> { throw new IllegalArgumentException(String.format("No validation defined for %s", key)); }).validate(validation.getValue()).isPresent(); } ValidationController(); @PostMapping({"/internal/validate", "/protected/validate"}) boolean validation(@Validated @RequestBody Validation validation); @GetMapping({"/internal/ipinfo", "/protected/ipinfo"}) IPInfo ipInfo(@RequestParam String ipAddress,
                         @RequestParam(required = false) Integer networkPrefix);  }