js-sdk-contrib
js-sdk-contrib copied to clipboard
[flagd-in-process] Add targeting validation and log warning
The Go/in-process, Java/in-process and standalone versions of flagd log a warning message with invalid targeting rules when they are fetched. We should implement this in the JS/in-process.
Targeting rules can be validated with the flags.json schema in conjunction with the targeting.json schema. Both will have to be loaded into AJV to fully validate. See similar examples in Go and Java
The in-process provider should be modified to use both of these schemas, and validate against them, only logging a warning if validation fails. Only a failure to parse the definition into a FeatureFlag instance should cause an abortive error (this means relaxing the existing validation to be consistent with all other impls which just do basic parsing).