edgexfoundry/go-mod-core-contracts

Optionally exclude validator from build

Closed this issue ยท 1 comments

๐Ÿš€ Feature Request

Relevant Package [REQUIRED]

go-mod-core-contracts

Description [REQUIRED]

The validator dependency is adding ~2MB memory footprint for each service:

func init() {
val = validator.New()
_ = val.RegisterValidation(dtoDurationTag, ValidateDuration)
_ = val.RegisterValidation(dtoUuidTag, ValidateDtoUuid)
_ = val.RegisterValidation(dtoNoneEmptyStringTag, ValidateDtoNoneEmptyString)
_ = val.RegisterValidation(dtoValueType, ValidateValueType)
_ = val.RegisterValidation(dtoRFC3986UnreservedCharTag, ValidateDtoRFC3986UnreservedChars)
_ = val.RegisterValidation(dtoInterDatetimeTag, ValidateIntervalDatetime)
}

But not all of them are actually using it.

It would be nice to be able to build service without this dependency.

Describe the solution you'd like

A no_dto_validator build flag and corresponding no-op code for the factory seem ideal this would make it easy to produce lighter builds.

Describe alternatives you've considered

Have you considered any alternative solutions or workarounds?

fixed by #744