albrow / forms Goto Github PK
View Code? Open in Web Editor NEWA lightweight go library for parsing form data or json from an http.Request.
License: MIT License
A lightweight go library for parsing form data or json from an http.Request.
License: MIT License
It would be cool if go-data-parser could perform basic validations for files uploaded via multipart form. Reading and validating the data might be overly-complex, but the following features seem reasonable:
I wanted to let the community know that I intend to make major changes to this library in the near future which will not be backwards compatible. I have updated the README with versioning information and recommend that for serious applications you use a dependency vendoring tool, such as godep.
The biggest change is that validation methods will be chainable, as they are in go-humble/form. IMO chainable methods read better and reduce code clutter. We could go from this:
val.Require("age")
val.TypeInt("age")
val.Greater("age", 0)
To this:
form.Validate("age").Required().Int().GreaterThan(0)
As a consequence, instead of calling Message
at the end of a validation method, we will need to introduce new methods for adding custom messages. Currently I am thinking to mimic go-humble/form and introduce methods with the f
suffix for adding custom messages.
// Requiredf is like Required but allows you to specify a custom error message.
// The arguments format and args work exactly like they do in fmt.Sprintf.
func (val *Validation) Requiredf(format string, args ...interface{}) *Validation
In addition, method names will be more consistent. I want the methods to read nicely without introducing too much verbosity.
currently when parsing multipart/form-data
requests, the size of data is locked in at 2048. For image uploads this might be a little low; is it possible to add the maximum size to the functions signature? Or perhaps a ParseMax(*http.Request, uint)
function?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.