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

Add strict mode and array fixed position validate #36

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

thanharrow
Copy link

No description provided.

Copy link
Owner

@miladibra10 miladibra10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution. It means a lot to me.

I put some comments that I think we can discuss more about them.

array.go Show resolved Hide resolved
schema.go Outdated
@@ -293,6 +313,26 @@ func (s *Schema) ValidateString(input string) error {

func (s *Schema) validateJSON(json gjson.Result) error {
var result error
if s.StrictMode {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand the point of StrictMode. validation will return an error if there is no value for the required fields.

Adding this mode will create a magic behavior for optional fields.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed for StrictMode, I think optional fields must be declared in schema struct. If it doesn't declared an optional fields, it show errors. I add some test, please check.

README.md Outdated Show resolved Hide resolved
array_test.go Outdated Show resolved Hide resolved
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.

2 participants