don't validate MinItems with unknowns in a block

If there are unknowns, the block may have come from a dynamic
declaration, and we can't validate MinItems. Once the blocks are
expanded, we will get the full config for validation without any unknown
values.
This commit is contained in:
James Bardin 2019-07-26 14:50:58 -07:00
parent 67dbd6d345
commit 4bed030d40
1 changed files with 9 additions and 0 deletions

View File

@ -1456,6 +1456,15 @@ func (m schemaMap) validateList(
"%s: should be a list", k)}
}
// We can't validate list length if this came from a dynamic block.
// Since there's no way to determine if something was from a dynamic block
// at this point, we're going to skip validation in the new protocol if
// there are any unknowns. Validate will eventually be called again once
// all values are known.
if isProto5() && !isWhollyKnown(raw) {
return nil, nil
}
// Validate length
if schema.MaxItems > 0 && rawV.Len() > schema.MaxItems {
return nil, []error{fmt.Errorf(