flask-rebar icon indicating copy to clipboard operation
flask-rebar copied to clipboard

CommaSeparatedList length validation

Open drnextgis opened this issue 5 years ago • 4 comments

How can I validate length of CommaSeparatedList? This is not working:

from marshmallow import fields, validate, Schema
from flask_rebar.validation import CommaSeparatedList

class Dummy(Schema):
    extent = CommaSeparatedList(
        fields.Float(),
        required=True,
        validates=validate.Length(equal=4)
    )

drnextgis avatar Sep 27 '19 12:09 drnextgis

Change that validates= to validate= and you should be good to go!

RookieRick avatar Sep 27 '19 17:09 RookieRick

Would be good to document that.

Sytten avatar Sep 29 '19 02:09 Sytten

Hmm, seems like that would be covered under https://marshmallow.readthedocs.io/en/stable/api_reference.html#module-marshmallow.fields since it's just standard Marshmallow behaviour.

I could see adding it as a recipe might be helpful though.

airstandley avatar Oct 08 '19 17:10 airstandley

Whoops accidentally closed this one early - agreed we could add a recipe to help with this

RookieRick avatar Nov 21 '19 21:11 RookieRick