| 158 | } |
| 159 | |
| 160 | func (f *FlagBase[T, C, V]) PreParse() error { |
| 161 | newVal := f.Value |
| 162 | |
| 163 | if f.Destination == nil { |
| 164 | f.value = f.creator.Create(newVal, new(T), f.Config) |
| 165 | } else { |
| 166 | f.value = f.creator.Create(newVal, f.Destination, f.Config) |
| 167 | } |
| 168 | |
| 169 | // Validate the given default or values set from external sources as well |
| 170 | if f.Validator != nil && f.ValidateDefaults { |
| 171 | if err := f.Validator(f.value.Get().(T)); err != nil { |
| 172 | return err |
| 173 | } |
| 174 | } |
| 175 | f.applied = true |
| 176 | return nil |
| 177 | } |
| 178 | |
| 179 | // Set applies given value from string |
| 180 | func (f *FlagBase[T, C, V]) Set(_ string, val string) error { |