workload validation before registering elektron. #19
|
@ -24,17 +24,6 @@ import "github.com/pkg/errors"
|
|||
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
||||
// Validator is a function that performs some sort of validation.
|
||||
// To keep things generic, this function does not accept any arguments.
|
||||
// In practice, a validator could be a closure.
|
||||
// Assume we are validating the below struct.
|
||||
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
||||
// type A struct { value string }
|
||||
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
||||
// One could then create a validator for the above struct like this:
|
||||
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
||||
// func AValidator(a A) Validator {
|
||||
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
||||
// return func() error {
|
||||
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
||||
// if a.value == "" {
|
||||
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
||||
// return errors.New("invalid value")
|
||||
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
||||
// }
|
||||
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
||||
// return nil
|
||||
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
||||
// }
|
||||
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
||||
// }
|
||||
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
||||
type Validator func() error
|
||||
|
||||
// Validate a list of validators.
|
||||
|
|
|||
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
![]() Do we need to keep this around? Do we need to keep this around?
![]() Yeah, the example might be an overkill. I'll get rid of it. Yeah, the example might be an overkill. I'll get rid of it.
|
Do we need to keep this around?