Skip to content

Commit

Permalink
don't validate MinItems with unknowns in a block
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jbardin committed Jul 27, 2019
1 parent 67dbd6d commit 4bed030
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions helper/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4bed030

Please sign in to comment.