marshmallow icon indicating copy to clipboard operation
marshmallow copied to clipboard

Suggestion: Refactor builtin fields to expose validators for re-use

Open bjmc opened this issue 7 years ago • 1 comments

For my use case, I want to have a custom field-getter using fields.Function() but the value it gets will be a UUID. I'd like to be able to have the same validation as the builtin fields.UUID(). However, that doesn't seem to be available in the validate module.

My suggestion is to refactor all the builtin field types so that they call validators in validate. That way, the same validators would also be exposed for reuse in custom user-defined fields.

As I'm imagining this, it would be a fully backwards-compatible change and the only difference to the public interface would be documenting/exposing new validators.

If that sounds like a good idea to the maintainers, I'm happy to take a crack at this and open a PR.

bjmc avatar Mar 28 '18 11:03 bjmc

Seems like a reasonable change to me. We'd certainly review a PR, @bjmc !

sloria avatar Apr 06 '18 03:04 sloria