Skip to content

[Feature Request] Allow custom localization in validate function #253

Open
@shaoerkuai

Description

@shaoerkuai

Is your feature request related to a problem? Please describe your use case.
I'm developing a open api application, and the validation error message should shown in user interface.

I suggest that We could modify the error message as I could

Describe the solution you'd like

Like this:

@validate(query=MyCustomQueryParams,message_writer=MyCustomWriter)
async def query_demo(request):
    return text("test")

async def MyCustomWriter (error_model):
   return 'extract the error detail from error_model and custom message to the user'

Additional context
error_model should be a list-dict, which contains the all encountered error

  1. the parameter name
  2. the error value
  3. the error type (wrong value type, missing required field,etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions