librelist archives

« back to archive

data validation?

data validation?

From:
Date:
2013-06-09 @ 14:02
Hi,

I have a REST API written in flask, and I'm looking for recommendations 
for frameworks that will validate the data that comes in from the 
requests. I'm not really thinking about this as specifically HTML form 
data, but that may not be an important distinction.

The kind of validations that are typical for me are:

- value must be an integer
- value must be >0
- value must be in some numeric range
- value must be a member of some given set of values
- if keyword "x" is specified, keyword "y" must also be specified
- if keyword "a" is specified, keyword "x" cannot be specified

This has been ridiculously tedious code to write, and it only recently 
occurred to me that there must be frameworks that do this kind of work. 
I'd also like to be able to return reasonably specific error messages 
through the API to guide the user as to exactly what went wrong. I'd also 
like to be able to write a custom validator when necessary.

Cheers,
Demitri

Re: [flask] data validation?

From:
Stefane Fermigier
Date:
2013-06-09 @ 14:13
On Jun 9, 2013, at 4:02 PM, thatsanicehatyouhave@me.com wrote:

> Hi,
> 
> I have a REST API written in flask, and I'm looking for recommendations 
for frameworks that will validate the data that comes in from the 
requests. I'm not really thinking about this as specifically HTML form 
data, but that may not be an important distinction.
> 
> The kind of validations that are typical for me are:
> 
> - value must be an integer
> - value must be >0
> - value must be in some numeric range
> - value must be a member of some given set of values
> - if keyword "x" is specified, keyword "y" must also be specified
> - if keyword "a" is specified, keyword "x" cannot be specified
> 
> This has been ridiculously tedious code to write, and it only recently 
occurred to me that there must be frameworks that do this kind of work. 
I'd also like to be able to return reasonably specific error messages 
through the API to guide the user as to exactly what went wrong. I'd also 
like to be able to write a custom validator when necessary.

These are some validation libraries from my "to check out when needed" 
list (I plan to have to use for one of these things someday, but this 
hasn't occurred yet):

http://docs.pylonsproject.org/projects/colander/en/latest/index.html
https://github.com/podio/valideer
https://github.com/halst/schema#readme
https://github.com/alecthomas/voluptuous

Feedback from people who have actually used them is very welcome...

Regards,

  S.

--
Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier 
- http://linkedin.com/in/sfermigier
Founder & CEO, Abilian - Enterprise Social Software - http://www.abilian.com/
Founder & board Member, Nuxeo - Open Source ECM - http://www.nuxeo.com/
Co-Founder and Chairman, Free&OSS Cluster - http://www.gt-logiciel-libre.org/
Co-Founder & Vice-President, National Council for Free&OSS - http://cnll.fr/

Re: [flask] data validation?

From:
Owein Reese
Date:
2013-06-09 @ 14:17
I almost forgot Schema: https://github.com/halst/schema The arbitrary data
validation library.
On Jun 9, 2013 10:16 AM, "Stefane Fermigier" <sfermigier@abilian.com> wrote:

>
> On Jun 9, 2013, at 4:02 PM, thatsanicehatyouhave@me.com wrote:
>
> > Hi,
> >
> > I have a REST API written in flask, and I'm looking for recommendations
> for frameworks that will validate the data that comes in from the requests.
> I'm not really thinking about this as specifically HTML form data, but that
> may not be an important distinction.
> >
> > The kind of validations that are typical for me are:
> >
> > - value must be an integer
> > - value must be >0
> > - value must be in some numeric range
> > - value must be a member of some given set of values
> > - if keyword "x" is specified, keyword "y" must also be specified
> > - if keyword "a" is specified, keyword "x" cannot be specified
> >
> > This has been ridiculously tedious code to write, and it only recently
> occurred to me that there must be frameworks that do this kind of work. I'd
> also like to be able to return reasonably specific error messages through
> the API to guide the user as to exactly what went wrong. I'd also like to
> be able to write a custom validator when necessary.
>
> These are some validation libraries from my "to check out when needed"
> list (I plan to have to use for one of these things someday, but this
> hasn't occurred yet):
>
> http://docs.pylonsproject.org/projects/colander/en/latest/index.html
> https://github.com/podio/valideer
> https://github.com/halst/schema#readme
> https://github.com/alecthomas/voluptuous
>
> Feedback from people who have actually used them is very welcome...
>
> Regards,
>
>   S.
>
> --
> Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier-
> http://linkedin.com/in/sfermigier
> Founder & CEO, Abilian - Enterprise Social Software -
> http://www.abilian.com/
> Founder & board Member, Nuxeo - Open Source ECM - http://www.nuxeo.com/
> Co-Founder and Chairman, Free&OSS Cluster -
> http://www.gt-logiciel-libre.org/
> Co-Founder & Vice-President, National Council for Free&OSS -
> http://cnll.fr/
>
>

Re: [flask] data validation?

From:
Owein Reese
Date:
2013-06-09 @ 14:06
If you're using forms or can get your data into edict format may I
recommend the excellent WTForms library? Can also add csrf testing that you
should use for open access api.
On Jun 9, 2013 10:04 AM, <thatsanicehatyouhave@me.com> wrote:

> Hi,
>
> I have a REST API written in flask, and I'm looking for recommendations
> for frameworks that will validate the data that comes in from the requests.
> I'm not really thinking about this as specifically HTML form data, but that
> may not be an important distinction.
>
> The kind of validations that are typical for me are:
>
> - value must be an integer
> - value must be >0
> - value must be in some numeric range
> - value must be a member of some given set of values
> - if keyword "x" is specified, keyword "y" must also be specified
> - if keyword "a" is specified, keyword "x" cannot be specified
>
> This has been ridiculously tedious code to write, and it only recently
> occurred to me that there must be frameworks that do this kind of work. I'd
> also like to be able to return reasonably specific error messages through
> the API to guide the user as to exactly what went wrong. I'd also like to
> be able to write a custom validator when necessary.
>
> Cheers,
> Demitri
>

Re: [flask] data validation?

From:
greatghoul
Date:
2013-06-09 @ 14:24
On Sun, Jun 9, 2013 at 10:06 PM, Owein Reese <owreese@gmail.com> wrote:

> WTForms


wtform +1
flask-wtf +1


-- 
 *greatghoul <http://www.g2w.me> - Ask and Learn!*

Re: [flask] data validation?

From:
dorian i
Date:
2013-06-09 @ 14:47
Validation library for Python designed to be used with JSON REST frameworks:
https://github.com/elasticsales/cleancat


On Sun, Jun 9, 2013 at 4:24 PM, greatghoul <greatghoul@gmail.com> wrote:

>
> On Sun, Jun 9, 2013 at 10:06 PM, Owein Reese <owreese@gmail.com> wrote:
>
>> WTForms
>
>
> wtform +1
> flask-wtf +1
>
>
> --
>  *greatghoul <http://www.g2w.me> - Ask and Learn!*
>