BodyReader

Parses and validates the HTTP POST body produced by an HTML form.

What it does

When this implementation of FieldReader is hit, the form POST body will be parsed into key-value pairs and validated according to the regex supplied in the settings, as outlined in the FieldReader article.

How it works

{
    instances = {
        writedata = SQL(f"queries/WriteAdres.sql"
            credset = "gefundeerd",
            params = ["id", "straat", "pandnummer",
                "postcode", "plaats", "provincie",
                "land", "omschrijving"]
        ) {                        
            oneaffected->Module(f"bekijk.conf@bydata");
        };

        form = Template(f"templates/BewerkFormulier.html") {
            landen->SQL(f"queries/Landen.sql",
                credset = "gefundeerd",
                params = ["land"],
                defaults = { land = "0"; }
            ) {
                iterator->Template(f"templates/Land.html");
            };
        };

        bydata = BodyReader(
            casesensitive = true,
            field_straat = ".{1,40}",
            field_pandnummer = "[0-9].{0,40}",
            field_postcode = "[0-9][0-9][0-9][0-9][A-Z][A-Z]",
            field_plaats = ".{1,40}",
            field_provincie = ".{0,40}",
            field_land = "[0-9]{0,9}",
            field_omschrijving = ".{0,40}",
            maperrors = true
        ) {
            failhandle->Module(f"../errors.conf");
            form->instances.form;
            successful->instances.writedata;
        };

        byid = Module(f"bekijk.conf@byid") {
            adresview->instances.bydata;
        };            

        byurl = Module(f"bekijk.conf@byurl") {
            adresview->instances.bydata;
        };
    };    
};

Settings

As described in FieldReader settings

Branches

As described in FieldReader branches