Skip to content

Add a data validation example #6

@Kangaroux

Description

@Kangaroux

By "data validation" I mean validating the actual values of the payload, not just the types. For example, we may want to check that a field is not blank.

I'm hesitant to use the term "form validation" since this library isn't really for form validation. It can certainly be used to help with form validation, but it's a bit redundant. It's more appropriate to use this for an API meant for third party consumers.

The straightforward approach to using this library for data validation would be:

  1. Input a JSON payload
  2. Use CompareMapToStruct() to check the types, and return the errors if there are any
  3. Unmarshal the JSON into dst and check the values using some validation logic, and return the errors if there are any

There are plenty of data validation libraries out there, like ozzo-validation, which would work pretty seamlessly with this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions