Skip to content

Multiple() implementation #2

@metal3d

Description

@metal3d

As I did on JS implementation, I recreate the issue there to discuss about "multiple" function.

Some implementation return the given value with "+", other give "{2,}"

To my side, for Go, I developped a method that have this implementation:

multiple(string value, int min, int max)

where:

  • min is the minimum number of occurence to get
  • maw is the maximum number of occurence to get

both argument are, IMHO, not required, default should be considered as doing "value?"

This is how I did:

// get "foo" at least one time
v.Multiple("foo")
v.Multiple("foo", 1)

// get "foo" 0 or more times
v.Multiple("foo", 0)

//get "foo" 0 or 1 times
v.Multiple("foo", 0, 1)

// get "foo" 0 to 10 times
v.Multiple("foo",0 ,10)

//get "foo" at least 10 times
v.Multiple("foo", 10)

//get "foo" exactly 10 times
v.Multiple("foo", 10, 10)

//get "foo" from 1 to 10 times
v.Multiple("foo", 1, 10)

Discussion is opened

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions