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: 11
Help us keep the lights on


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!

2.0.0-rc.2 - Mar 9, 2019


  • Ensures that fields defined on the Submittable type (through makeAdditionalFields) are included when using the preCreate and preLogin functions.

2.0.0-rc.1 - Mar 6, 2019

Redesigned API to be more flexible and powerful. Updates to README will follow soon.