Skip to content

Conversation

fredbi
Copy link
Contributor

@fredbi fredbi commented Jan 10, 2021

This PR adds support for minProperties and maxProperties validations in objects.

  • The validation remains standalone, independent from unmarshalling
  • The validation doesn't use json for plain maps, just len()
  • There is short-circuit to invalidate faster nil objects requiring at least one property.
  • The general case of objects with properties and additional properties requires intermediary JSON
    serialization.

Signed-off-by: Frederic BIDON fredbi@yahoo.com

* fixes go-swagger#2444

This PR adds support for minProperties and maxProperties validations in objects.

* The validation remains standalone, independent from unmarshalling
* The validation doesn't use json for plain maps, just len()
* There is short-circuit to invalidate faster nil objects requiring at least one property.
* The general case of objects with properties and additional properties requires intermediary JSON
  serialization.

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@codecov
Copy link

codecov bot commented Jan 10, 2021

Codecov Report

Merging #2477 (3519c91) into master (52c4a5d) will decrease coverage by 0.06%.
The diff coverage is 53.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2477      +/-   ##
==========================================
- Coverage   81.90%   81.84%   -0.07%     
==========================================
  Files          53       53              
  Lines        8332     8343      +11     
==========================================
+ Hits         6824     6828       +4     
- Misses       1017     1023       +6     
- Partials      491      492       +1     
Impacted Files Coverage Δ
generator/types.go 91.26% <41.66%> (-0.98%) ⬇️
generator/model.go 84.83% <100.00%> (ø)
generator/template_repo.go 88.69% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 52c4a5d...3519c91. Read the comment docs.

@fredbi fredbi merged commit f31a9a3 into go-swagger:master Jan 10, 2021
@fredbi fredbi deleted the add-minmax-properties-validation branch January 11, 2021 12:47
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.

model validations: support minProperties and maxProperties
1 participant