aerogear / charmil

The framework for building modular plugin based CLI's using Cobra and Golang
https://aerogear.github.io/charmil
Apache License 2.0
116 stars 13 forks source link

feat: disable validation rule option #202

Closed ankithans closed 3 years ago

ankithans commented 3 years ago

Closes #197

Description

I tried doing it with loop, but it gives problem. Here is the sample code which I tried.

r := reflect.ValueOf(validatorConfig.ValidatorRules)
for i := 0; i < r.NumField(); i++ {
    a := r.Field(i)
        fmt.Println(a.FieldByName("RuleOptions").FieldByName("Disable").String())

    if a.FieldByName("RuleOptions").FieldByName("Disable").String() == "false" {
        ruleConfig.Rules = append(ruleConfig.Rules, a.interface{}.(Rules))  // here is the issue
        }

    fmt.Println(ruleConfig.Rules)
}

Type of change

Checklist