Submissions to the Package dependencies:
dependencies: [ ..., .package(url: "https://github.com/nodes-vapor/submissions.git", from: "2.0.0-beta") ]
as well as to your target (e.g. "App"):
targets: [ ... .target( name: "App", dependencies: [... "Submissions" ...] ), ... ]
Submissions was written to reduce the amount of boilerplate needed to write the common tasks of rendering forms and processing and validating data from POST/PUT/PATCH requests (PPP-request, or submission for short). Submissions makes it easy to present detailed validation errors for web users as well as API consumers.
Submissions is designed to be flexible. Its functionality is based around
Fields which are abstractions that model the parts of a submission.
single values with its validators and meta data such as a label. Usually a form or API request involves multiple properties comprising a model. This can be modeled using multiple
Getting started 🚀
First make sure that you've imported Submissions everywhere it's needed:
Adding the Provider
"Submissions" comes with a light-weight provider that we'll need to register in the
configure function in our
This makes sure that fields and errors can be stored on the request using a
Defining your submitted data
Validating API requests
Validating HTML form requests
Rendering the forms
Validating and storing the data
This package is open-sourced software licensed under the MIT license.
Help us keep the lights on
2.0.0-rc.7 - Jun 5, 2019
- A Leaf tag for the
selectHTML element. See https://github.com/nodes-vapor/submissions/pull/46 for an example of how to use it.
2.0.0-rc.6 - May 7, 2019
- Consistently default to
- Fixed Swift 5 compiler warnings related to redundant access modifiers
- Make sure a
Submissionmade from a
Submittableis also used for making the
Submittable's additional fields in
2.0.0-rc.5 - Apr 5, 2019
- support for array values in URLEncoded forms
Field's properties are now public.
- removed redundant "form-control" class from file-input leaf.
All of these come, once again, courtesy of @MrMage!
2.0.0-rc.4 - Mar 28, 2019
SubmissionsDatas properties are now public as the type was already before. Thanks to @MrMage!
2.0.0-rc.3 - Mar 22, 2019
- Typo in errorOnAbsense parameter: absense -> absence. Thanks @MrMage!