-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.cpp
More file actions
27 lines (25 loc) · 1.25 KB
/
schema.cpp
File metadata and controls
27 lines (25 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "JsonValidator.hpp"
ObjectValidator locationSchema = obj()
.property("allowed_methods",arr().item(
Or()
.addConditions(str().isEqual("GET"))
.addConditions(str().isEqual("POST"))
.addConditions(str().isEqual("DELETE"))
.withMsg("Allowed methods must be GET, POST or DELETE!"))
.max(3))
.property("auto_index", Bool().withDefault(false))
.property("cgi", obj().match(str().notEmpty(), str().notEmpty().isValidPath())
.property("upload_dir", str().notEmpty())).optional();
ArrayValidator ServerSchema = arr().item(
obj()
.property("server_name", str().notEmpty())
.property("host", str().notEmpty())
.property("port", arr().item(num().min(0).max(65535)).min(1))
.property("redirects", obj().match(str().isStartWith('/'),str().isStartWith('/'))).optional()
.property("error_pages", obj().match(str().isDigit(), str().notEmpty())).optional()
.property("default_root", str().notEmpty().isValidDir())
.property("default_index", arr().item(str().notEmpty()))
.property("location", obj().match(str().notEmpty().isStartWith('/'), locationSchema))
.property("list_dir", Bool().withDefault(false))
.property("client_max_body_size", num().min(0).withDefault(1024)))
.min(1);