mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
refactor view validator
This commit is contained in:
parent
384329bc91
commit
5de9a7d0d0
2 changed files with 2 additions and 19 deletions
10
client.go
10
client.go
|
|
@ -394,15 +394,7 @@ func (c *Client) ExportCSV(ctx context.Context, index, frame, view string, slice
|
|||
return ErrIndexRequired
|
||||
} else if frame == "" {
|
||||
return ErrFrameRequired
|
||||
}
|
||||
foundView := false
|
||||
for _, v := range []string{ViewInverse, ViewStandard} {
|
||||
if view == v {
|
||||
foundView = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if foundView == false {
|
||||
} else if !(view == ViewStandard || view == ViewInverse) {
|
||||
return ErrInvalidView
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,22 +49,13 @@ func NewExportCommand(stdin io.Reader, stdout, stderr io.Writer) *ExportCommand
|
|||
// Run executes the export.
|
||||
func (cmd *ExportCommand) Run(ctx context.Context) error {
|
||||
logger := log.New(cmd.Stderr, "", log.LstdFlags)
|
||||
foundView := false
|
||||
|
||||
// Validate arguments.
|
||||
if cmd.Index == "" {
|
||||
return pilosa.ErrIndexRequired
|
||||
} else if cmd.Frame == "" {
|
||||
return pilosa.ErrFrameRequired
|
||||
}
|
||||
|
||||
for _, v := range []string{pilosa.ViewInverse, pilosa.ViewStandard} {
|
||||
if cmd.View == v {
|
||||
foundView = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if foundView == false {
|
||||
} else if !(cmd.View == pilosa.ViewStandard || cmd.View == pilosa.ViewInverse) {
|
||||
return pilosa.ErrInvalidView
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue