Rocket/codegen/tests/run-pass/empty_form.rs
Sergio Benitez a3ea9d0f9a Add support for lenient forms via 'LenientForm'.
This commit changes the 'FromForm' trait in two ways:

  1. The singular method is now named 'from_form'.
  2. The method takes a second parameter: 'strict: bool'.

The 'strict' parameter is used to specify whether form parsing should
be strict or not (i.e. lenient). When parsing is lenient, extra form
fields do not result in an error. This lenient behavior is used by a
new 'LenientForm' data guard type to request lenient form parsing. The
behavior for 'Form' remains unchanged.

Resolves #242.
2017-06-18 01:59:22 -07:00

19 lines
448 B
Rust

#![feature(plugin, custom_derive)]
#![plugin(rocket_codegen)]
extern crate rocket;
use rocket::request::{FromForm, FormItems};
#[derive(PartialEq, Debug, FromForm)]
struct Form { }
fn main() {
// Same number of arguments: simple case.
let task = Form::from_form(&mut FormItems::from(""), true);
assert_eq!(task, Ok(Form { }));
let task = Form::from_form(&mut FormItems::from(""), false);
assert_eq!(task, Ok(Form { }));
}