[ValidationHandler] How to validate without the deprecated stuff?

576 views
Skip to first unread message

Philippe MAGDELENAT

unread,
Dec 23, 2022, 5:35:31 AM12/23/22
to vert.x
Hi,

First thing first let me introduce myself. I am Philippe, moved on the product side for the last decade (and more), trying to get things done with Vert.x to get some pleasure and learn as of now bu, hopefully  for more in the future. And by the way thanks for this list for it gave me precious info over and over again.

My issue might be very simple but I can't figure how to validate a route since the method I wanted to use is now deprecated. In the not so distant past I would have done something like :

public ValidationHandler redirect() {
      SchemaParser schemaParser = SchemaParser.createDraft7SchemaParser(SchemaRouter.create(vertx, new SchemaRouterOptions()));

      return ValidationHandler
                      .builder(schemaParser)
                      .pathParameter(Parameters.param("key", stringSchema()))
                      .build();
}

The idea here is to ensure that the called url has the key parameter in its path (like http://localhost:8080/one-value (where one-value would be the key path parameter).

Do you know how I could do that without deprecation? It's probably trivial but I am lost and the doc only states "Deprecated users should migrate to the new validator" but I can't figure how :-(

Thanks!

philippe

Bruno F

unread,
Dec 24, 2022, 8:16:22 AM12/24/22
to vert.x
Hi,

It is hard to say without any package name, jar name and version number.
Latest docs are mentioning a ValidationHandlerBuilder class:
ValidationHandlerBuilder
 .create(schemaParser)
 .pathParameter(Parameters.param("myPathParam", stringSchema()))

You're using an interface (?) called ValidationHandler.

Bruno.

Philippe MAGDELENAT

unread,
Dec 24, 2022, 8:23:24 AM12/24/22
to ve...@googlegroups.com
Hi Bruno,

Thanks for the answer. To clarify, my issue is that I don’t know how to create a SchemaParser to use for my validation but with the deprecated call below:

SchemaParser schemaParser = SchemaParser.createDraft7SchemaParser(SchemaRouter.create(vertx, new SchemaRouterOptions()));

I am ok with the doc on validation (and it works perfectly if I accept the deprecation warning) but I can’t get to see how I create the schemaParser but with the deprecated above call :-( The idea here is to get read of the deprecation warning to be ready for future releases (and doing the validation the right way).

Philippe

--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/36_jADUrDVA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/f18bb3b5-b141-49c5-8816-f9273647195fn%40googlegroups.com.

Bruno F

unread,
Dec 24, 2022, 8:44:33 AM12/24/22
to vert.x
The Deprecated annotation has been added on May the 2nd, a few days before the release of vert.x 4.3.
Release notes are mentioning a major update of json schema validation:
It is probably (?) referring to:
Validator.create(schema, new JsonSchemaOptions().setDraft(Draft.DRAFT7))

Bruno.
Reply all
Reply to author
Forward
0 new messages