Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom validations #440

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

soumiksamanta
Copy link
Contributor

Adding custom validation to container. Though it's not what we want in the longer run. We need to handle the custom validation in a more generic way.

@googlebot googlebot added the cla: yes This PR author has signed the CLA label Sep 4, 2020
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.002%) to 90.726% when pulling 655143c on soumiksamanta:custom_validations into c6ce7e5 on openconfig:master.

@robshakir
Copy link
Contributor

I think this version is a bit more confusing than what we have today - I suspect what we need is to have:

type CustomValidator struct {
  T reflect.Type
   Fn func(interface{}) error
}

such that we can load in each case - then each Validate function should check the type against a map[reflect.Type]func(interface{}) error and execute that function if we've been asked to.

This approach seems to make the function half-way generic -- it's generic, but just for containers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This PR author has signed the CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants