Skip to content

Conversation

@ae0000
Copy link

@ae0000 ae0000 commented May 20, 2014

I added the ability to provide parameters to the validation, like: maxLength[123]

Unfortunately it breaks the API by requiring the validation functions to accept an extra parameter.

But - thought I'd sent it back in case you wanted it :)

@mccoyst mccoyst self-assigned this May 20, 2014
@mccoyst
Copy link
Owner

mccoyst commented May 20, 2014

This is cool, and thank you very much for the PR, but I don't like breaking the API. Maybe separate parameterized validators into their own type with its own Validate method? E.g. type P map[string]func(interface{}, []string) error. The existing V could ignore validators with params, and P could ignore those without. Something like that — I'll have to put more thought into it.

This also needs a bit more robust checking of the syntax of parameters. It at least needs to verify that the closing ] is present. And if we want to go the extra mile, allow | to be escaped so that it can appear in params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants