Byte
Path:
/src/type/byte.coffeecompiled to/lib/type/byte.js
To test for byte values which may contain prefixes like 18M or 6.2 GB.
Sanitize options allowed:
unit-Stringunit to convert to if no number is givenround-Booleanrounding can be set to true for arithmetic rounding or usefloororceilfor the corresponding methodsdecimals-Integernumber of decimal digits to round to
Check options:
min-Integerthe smalles allowed numbermax-Integerthe biggest allowed number
This supports the units: B, Bytes, b, bps, bits
Schema Specification
Byte is a definition for number of bytes or bits.
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 unit.
A text entry which is optional and will be set to
'B'if not specified. All control characters will be removed. 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]$/.
- An object which has to be an instance of class
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.