From 9b8a50b964fcd7c62aa5e5d2e967d03c5fdfb6b6 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Thu, 4 Mar 2021 14:09:13 +0100 Subject: [PATCH] add func (c *FormatCheckerChain) List() []string Signed-off-by: Pierre Fenoll --- format_checkers.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/format_checkers.go b/format_checkers.go index 1e770464..65b6e222 100644 --- a/format_checkers.go +++ b/format_checkers.go @@ -172,6 +172,18 @@ func (c *FormatCheckerChain) Has(name string) bool { return ok } +// List lists by name all FormatChecker held in the FormatCheckerChain +func (c *FormatCheckerChain) List() []string { + names := make([]string, 0, 18) + lock.RLock() + for name := range c.formatters { + names = append(names, name) + } + lock.RUnlock() + + return names +} + // IsFormat will check an input against a FormatChecker with the given name // to see if it is the correct format func (c *FormatCheckerChain) IsFormat(name string, input interface{}) bool {