Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added array support #13

Merged
merged 2 commits into from
Mar 12, 2024
Merged

feat: Added array support #13

merged 2 commits into from
Mar 12, 2024

Conversation

Jamess-Lucass
Copy link
Owner

Adds support for schema.Array()
Comes with functions:

  • Min
  • Max

takes an argument of any type that implements the ISchema interface.

examples:

schema.Array(schema.String())
schema.Array(schema.String()).Min(1)
// Requires at least 1 element in the array
schema.Array(schema.String().Max(10)).Min(1)
// Requires at least 1 element in the array where the item has a max length of 10
schema.Array(schema.Object(map[string]schema.ISchema{
    "Firstname": schema.String().Min(4),
}))

// An array of objects where the property `Firstname` must be a string of minimum 4 characters

// [{Firstname: "john"}, {Firstname: "Doe"}] // 1st is valid, 2nd is invalid

@Jamess-Lucass Jamess-Lucass merged commit 836356e into main Mar 12, 2024
3 checks passed
@Jamess-Lucass Jamess-Lucass deleted the feat/arrays branch March 12, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant