Interval

Path: /src/type/interval.coffee compiled to /lib/type/interval.js

A time interval may be given:

  • directly as number
  • in a string with days, minutes and seconds: 1d 3h 12m 10s 400ms
  • in a time format: 03:20, 02:18:10.5

Sanitize options allowed:

  • unit - String type of unit to convert if not integer given
  • round - Boolean rounding can be set to true for arithmetic rounding or use floor or ceil for the corresponding methods
  • decimals - Integer number of decimal digits to round to (defaults to 2)

Check options:

  • min - Integer the smallest allowed number
  • max - Integer the biggest allowed number

Schema Specification

Interval is an interval schema definition.

An object with the following keys allowed: unit, round, decimals, min, max, title, description, key, type, optional, default. The following entries have a specific format:

unit

Source Unit is the unit in which an only numeric value is given, will transform to base value.

A text entry which is optional. All control characters will be removed. Only the values: ‘d’, ‘h’, ‘m’, ‘s’, ‘ms’ are allowed.

round

Rounding is the value can be rounded in different ways.

It has to be one of the following types (optional):

  • Arithmetic Rounding is a flag which allows arithmetic rounding (till 4 down, from 5 up) if set to true.

    A boolean value, which will be true for ‘true’, ‘1’, ‘on’, ‘yes’, ‘+’, 1, true and will be considered as false for ‘false’, ‘0’, ‘off’, ‘no’, ‘-’, 0, false.

  • Alternative Rounding is the alternative rounding method to be used.

    A text entry in which all control characters will be removed. Only the values: ‘floor’, ‘ceil’ are allowed.

decimals

Decimals are the number of decimal digits to round to.

An integer value which is optional. The value should be greater than 0.

min

Min Value is the minimal value to be set.

A numeric floating point number which is optional.

max

Max Value is the maximal value to be set.

A numeric floating point number which is optional. The value should be greater than <<>>.

title

Title is the title used to describe the element.

A text entry which is optional. All control characters will be removed.

description

Description is the free description of the element.

A text entry which is optional. All control characters will be removed.

key

Binding to Keyname is the mapping to which key names in an object this element belongs.

A valid regular expression which is optional. It has to be one of the following types:

  • An object which has to be an instance of class RegExp.
  • A text entry in which all control characters will be removed. The text should match: /^/.?/[gim]$/.
type

Type is the type of element.

A text entry in which all control characters will be removed.

optional

Optional is a flag defining if this element is optional.

A boolean value, which will be true for ‘true’, ‘1’, ‘on’, ‘yes’, ‘+’, 1, true and will be considered as false for ‘false’, ‘0’, ‘off’, ‘no’, ‘-’, 0, false. It’s optional.

default

Default Value is the default value to use if nothing given.

A numeric floating point number which is optional.