Skip to content

Enforcing required fields presence #544

@francescom-zenity

Description

@francescom-zenity

Hi,

I wish the generated code had a method "Validate()" or similar that, given a Go struct instance, checks whether all required fields are present and whether their content is compliant with the JSON schema.
This would be very useful during e.g. unit testing:

testStruct := myMethodThatPopulatesRequestMsg()
// t is an instance of generatedGoStruct
assert.True(t, testStruct.Validate()) // check that all fields were populated successfully

Is this achievable somehow today?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions