Validate validates the library configuration is well-formed. For example, setting both the IncludeMacros and ExcludeMacros together could be confusing and create a broken expectation, likewise for IncludeFunctions and ExcludeFunctions.
()
| 557 | // For example, setting both the IncludeMacros and ExcludeMacros together could be confusing |
| 558 | // and create a broken expectation, likewise for IncludeFunctions and ExcludeFunctions. |
| 559 | func (lib *LibrarySubset) Validate() error { |
| 560 | if lib == nil { |
| 561 | return nil |
| 562 | } |
| 563 | var errs []error |
| 564 | if len(lib.IncludeMacros) != 0 && len(lib.ExcludeMacros) != 0 { |
| 565 | errs = append(errs, errors.New("invalid subset: cannot both include and exclude macros")) |
| 566 | } |
| 567 | if len(lib.IncludeFunctions) != 0 && len(lib.ExcludeFunctions) != 0 { |
| 568 | errs = append(errs, errors.New("invalid subset: cannot both include and exclude functions")) |
| 569 | } |
| 570 | return errors.Join(errs...) |
| 571 | } |
| 572 | |
| 573 | // SubsetFunction produces a function declaration which matches the supported subset, or nil |
| 574 | // if the function is not supported by the LibrarySubset. |