validator_base_date (zotonic_mod_base v1.0.0-rc.17)

Validate input date against a given date format.

A quick guide to validating a date in Zotonic:

<input type="text" id="my_date" name="my_date" value="" />
{% validate id="my_date" type={date separator="-" format="b"} %}

This code validates when the user enters a date in the following format:

yyyy-mm-dd

Arguments

ArgumentDescriptionExample
separatorCharacter used to separate date parts, such as / - \\. Defaults to "-".separator="-"
formatDate format, big endian (starting with year), little endian (starting with day) or middle endian (starting with month). Defaults to "l" (little).format="m"

Summary

Functions

render_validator/5

validate/5

-spec validate(term(), term(), term(), list(), z:context()) ->
                  {{ok, term()}, z:context()} | {{error, term(), term()}, z:context()}.