Skip to content

[good first issue] Add missing built in validators #154

@Oudwins

Description

@Oudwins

Hey everyone!

So many people have asked me about contributing and I always reply the same thing so I thought I'll take a bit of time to write up a bit of guidance if you want to try to contribute to the project.

Firstly awesome! You rock! thanks for taking the time!

If you are here I assume you are not sure how to get started or are looking for ideas for your first PR.

I suggest you start by creating a new builtin Test (what Zog calls validations). This is quite simple, here is how I would go about doing so:

  1. Go to https://zod.dev/ or https://github.com/go-playground/validator or some other validation library
  2. Find a validation that Zog doesn't have built in yet and you think we should have (it won't be hard since we are still missing a lot)
  3. read the contributing guide
  4. head to the schema where you want to add the test. Lets say the string schema, that is in string.go (easy right?)
  5. Find another test something like the Min method. Copy that and adapt it to the new test you are adding
  6. Head to zconst and add the issueCode for the test as a constant
  7. Head to /i18n/en/en.go and add the default message to the json like map
  8. Write a test for validate & one for parse in the {schema}_test.go and {schema}_validate_test.go files
  9. Add the new test to the reference.md in the docs (just one line with the test name like all the others under the specific schema)
  10. You are done! Congrats
  11. Make the PR and wait until I have a chance to see it. Please be patient, I'm lazy and it takes me quite a bit of time to get to the PRs some times.appy contributing!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions