QueryReader

Parses and validates the an query string using Functionality provided by FieldReader

What it does

When this implementation of FieldReader is hit, an URL query string will be parsed into key-value pairs and validated according to the regexes supplied in the Settings, as outlined in the FieldReader-article.

How it works

{
    instances = {
        viewadres = Template(f"templates/Adres.html");
        nietsgevonden = Template(f"templates/IdNietGevonden.html");

        bydata = SQL(f"queries/AdresLand.sql",
            credset = "gefundeerd"    
            params = ["land"]
        ) {
            none->instances.viewadres;
            single->instances.viewadres;
        };

        byid = SQL(f"queries/AdresByID.sql",
            credset = "gefundeerd",
            params = ["id"]
        ) {
            none->instances.nietsgevonden;
            single->Return("adresview") {
                default->instances.bydata;
            };
            iterator->instances.nietsgevonden;
        };

        byurl = QueryReader(field_id = "[0-9]+") {
            // reads the id from the URL query string, ie.
            // when presented with http://foo.bar/?id=3, will
            // assign 3 to id in context.
            form->Template(f"templates/IdNietGegeven.html");
            successful->instances.byid;
        };
    };
}

Settings

As described in FieldReader settings

Branches

As described in FieldReader branches