You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
kun has already supported request validation since #10. However, there are some disadvantages:
The request validation is done at the transport layer, while the request fields to validate are actually designed at the service layer
Input validation of pure services (i.e. without the transport layer) are not supported, which is a critical problem since "In-process function call" is the communication type kun must support.
Validation schemas are not visible from the documentation (i.e. Godoc for pure services, OAS for HTTP services, Protobuf for gRPC services, etc)
Validation Grammar
Validation grammars from the current leading Go frameworks:
// Service is used for saying hello.typeServiceinterface {
// SayHello says hello to the given name.//// @schema:// name: len(0, 10).msg("bad length") && match(`^\w+$`)////kun:op POST /messagesSayHello(ctx context.Context, namestring) (messagestring, errerror)
}
and this is the corresponding generated service middleware:
Problem
kun
has already supported request validation since #10. However, there are some disadvantages:kun
must support.Validation Grammar
Validation grammars from the current leading Go frameworks:
Other interesting references:
Proposed Solution
Example
helloworld
Take the helloworld service as an example, the validation schemas become (see previous schema definition):
and this is the corresponding generated service middleware:
usersvc
Take the usersvc an example, the schema definition will be:
and this is the corresponding generated service middleware:
The text was updated successfully, but these errors were encountered: