Adds type="color" to string types
Adds type="date" to string types
Adds type="datetime-local" to string types
Adds disabled to any input
Adds type="email" to string types
Adds type="month" to string types
Makes string types textareas
Disables automatic JS saving when changing the input
Changes a dropdown to a radio button list
Adds type="password" to string types
Adds type="range" to numeric types
Adds required to any input
Adds type="time" to string types
Adds type="url" to string types
Adds type="week" to string types
Converts correctBookISBN_number to "Correct Book ISBN Number"
Function processing user input and validating for correctness.
The following validations are done:
If the setting is a disabledSetting, it will always skip this field.
If the setting has a settingPattern, it will validate the raw value (no matter what type) against this regex.
If the setting is a number, std.conv.to will be used to try to convert it to a double and then it will be cast to the type after checking min/max/step.
If the setting is a BitFlags!T every passed argument will be checked if it is contained inside the enum T or when submitted via JS only the one specified argument will get validated and inverted if starting with !
If the setting is an enum the value will be checked if it is contained inside the enum.
Additionally if the setting is a floating point number and there hasn't been a min/max setup but it is a rangeSetting, the number will be finite.
Integral numbers will always be checked if finite & if no range is given they will be clamped.
Attributes for strings:
emailSetting is validated using std.net.isemail.isEmail(CheckDns.no, EmailStatusCode.any)
urlSetting is validated using vibe.inet.url.URL
timeSetting is checked against pattern 00:00 + checking if 0 <= hour < 24 && 0 <= minute < 60
weekSetting is checked against pattern 0{4,6}-W00 + checking if 1 <= year <= 200000 && 1 <= week <= 52
monthSetting is checked against pattern 0{4,6}-00 + checking if 1 <= year <= 200000 && 1 <= month <= 12
datetimeLocalSetting is checked against pattern 0000-00-00T00:00 + passing into std.datetime.SysTime.fromISOExtString`
dateSetting is checked against pattern 0000-00-00 + checking the date using std.datetime.Date
colorSetting is checked against pattern #FFFFFF
Values using these attributes can be used without the need to validate the input.
Function processing user input and validating for correctness.
The following validations are done:
If the setting is a disabledSetting, it will always skip this field.
If the setting has a settingPattern, it will validate the raw value (no matter what type) against this regex.
If the setting is a number, std.conv.to will be used to try to convert it to a double and then it will be cast to the type after checking min/max/step.
If the setting is a BitFlags!T every passed argument will be checked if it is contained inside the enum T or when submitted via JS only the one specified argument will get validated and inverted if starting with !
If the setting is an enum the value will be checked if it is contained inside the enum.
Additionally if the setting is a floating point number and there hasn't been a min/max setup but it is a rangeSetting, the number will be finite.
Integral numbers will always be checked if finite & if no range is given they will be clamped.
Attributes for strings:
emailSetting is validated using std.net.isemail.isEmail(CheckDns.no, EmailStatusCode.any)
urlSetting is validated using vibe.inet.url.URL
timeSetting is checked against pattern 00:00 + checking if 0 <= hour < 24 && 0 <= minute < 60
weekSetting is checked against pattern 0{4,6}-W00 + checking if 1 <= year <= 200000 && 1 <= week <= 52
monthSetting is checked against pattern 0{4,6}-00 + checking if 1 <= year <= 200000 && 1 <= month <= 12
datetimeLocalSetting is checked against pattern 0000-00-00T00:00 + passing into std.datetime.SysTime.fromISOExtString`
dateSetting is checked against pattern 0000-00-00 + checking the date using std.datetime.Date
colorSetting is checked against pattern #FFFFFF
Values using these attributes can be used without the need to validate the input.
Generates a single input
Generates a HTML form for a configuration struct T with automatic instant updates using AJAX.
The fields can be annotated with the various UDAs found in this module. (setting enums + structs)
Supported types: enum (drop down lists or radio box lists), std.typecons.BitFlags (checkbox lists),
bool (checkbox), string types (text, email, url, etc.), numeric types (number), std.datetime.DateTime
(datetime-local), std.datetime.Date (date), std.datetime.TimeOfDay (time), vibe.inet.URL (url),
string[] (textarea taking each line)
Validates s == pattern "#xxxxxx"
Validates s == pattern "0000-00-00"
Validates s == pattern "0000-00-00T00:00"
Validates s == pattern "0{4,6}-00"
Validates s == pattern "00:00"
Validates s == pattern "0{4,6}-W00"
Contains a updateSetting(input) function which automatically sends changes to the server.
Controls how the input HTML is generated
Relables all enum member names for a language. Give null as first argument to change the default language
Changes how the form HTML template looks
Inserts raw CSS class name for an element.
Inserts raw HTML code before an element.
Overrides the label of the input
Changes the minlength="" and maxlength="" attribute for string values
Changes the max="" attribute for numerical values
Changes the min="" attribute for numerical values
Changes the pattern="regex" attribute
Sets the placeholder attribute for elements that support it
Changes the min="" and max="" attribute for numerical values
Sets the number of rows of a textarea
Changes the step="" attribute for numerical values
Changes the title="" attribute for custom error messages & tooltips
Changes the label if the current language (using a WebInterface translation context) matches the given one. You need at least vibe-d v0.8.1-alpha.3 to use this UDA.
Main package containing all neccesarry functions