Swiftpack.co - Package - nodes-vapor/submissions

Submissions 📩

Swift Version Vapor Version CircleCI codebeat badge codecov Readme Score GitHub license



Add 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: [
        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 Fields.

Getting started 🚀

First make sure that you've imported Submissions everywhere it's needed:

import Submissions

Adding the Provider

"Submissions" comes with a light-weight provider that we'll need to register in the configure function in our configure.swift file:

try services.register(SubmissionsProvider())

This makes sure that fields and errors can be stored on the request using a FieldCache service.

Defining your submitted data

Validating API requests

Validating HTML form requests

Leaf tags

Rendering the forms

Validating and storing the data

🏆 Credits

This package is developed and maintained by the Vapor team at Nodes. The package owner for this project is Siemen.

📄 License

This package is open-sourced software licensed under the MIT license.


Stars: 12
Help us keep the lights on


2.0.0-rc.7 - Jun 5, 2019


  • A Leaf tag for the select HTML 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 false for isRequired for all Field initializers


  • Fixed Swift 5 compiler warnings related to redundant access modifiers
  • Make sure a Submission made from a Submittable is also used for making the Submittable's additional fields in Submittable.makeFields

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!