openrtb icon indicating copy to clipboard operation
openrtb copied to clipboard

Validatiors not conforming to IAB specifications ?

Open renomarx opened this issue 4 years ago • 2 comments

Hello,

I think there are some contradictions with IAB OpenRTB specifications on validators:

For example, in IAB specifications, it seems that an imp object can contain a video object and/or a banner object.

The presence of a Videoas a subordinate ofthe Impobject indicates that this impression is offered as a video type impression. At the publisher’s discretion, that same impression may also be offered as banner, audio, and/or native by also including as Impsubordinates objects of those types. However, any given bid for the impression must conform to one of the offered types.

Source: https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-API-Specification-Version-2-5-FINAL.pdf

But here is the code of the validator:


func (imp *Impression) assetCount() int {
	n := 0
	if imp.Banner != nil {
		n++
	}
	if imp.Video != nil {
		n++
	}
	if imp.Native != nil {
		n++
	}
	return n
}

// Validate the `imp` object
func (imp *Impression) Validate() error {
	if imp.ID == "" {
		return ErrInvalidImpNoID
	}

	if count := imp.assetCount(); count > 1 {
		return ErrInvalidImpMultiAssets
	}

	if imp.Video != nil {
		if err := imp.Video.Validate(); err != nil {
			return err
		}
	}

	return nil
}

Is there any particular reason for that behavior ?

renomarx avatar Feb 11 '21 17:02 renomarx

Good point, do you mind adding a pull request to address?

dim avatar Feb 12 '21 09:02 dim

Sure, I'll do that by the end of next week.

renomarx avatar Feb 16 '21 13:02 renomarx