LCONF LOGO

This file is part of the LCONF-Data-Serialization-Format-Standard Documentation.

Copyright (c) 2014 - 2015, peter1000 https://github.com/peter1000.

7. LCONF-Schema-Definitions

LCONF uses LCONF-Schema-Definitions to descripe the structure and default content as well as any constraints on the structure and content of a LCONF-Section, above and beyond the basic syntactical constraints imposed by LCONF itself. LCONF-Schema-Definitions are valid LCONF syntax with the exception that LCONF-Schema-Identifier-Lines (which are STRUCTURE_SINGLE_BLOCKs) consists of additional info split by a LCONF_SCHEMA_SEPARATOR (LCONF_VERTICAL_LINE).

7.1. LCONF-Schema-Formats

There are two supported LCONF-Schema-Formats:

All LCONF-Libraries MUST support the LCONF_FORMAT_SCHEMA_STRICT and MAY implement individual LCONF_FORMAT_SCHEMA_FLEXIBLE.

All LCONF-Schema-Definition Sections MUST set the used LCONF-Schema-Format in the: LCONF-Section Start Line:

LCONF-Schema-Definition Section-Start-Line MUST

___SECTION :: 4 :: STRICT :: Menu Configuration Schema Definition`
___SECTION :: 4 :: FLEXIBLE :: Menu Configuration Schema Definition`

7.1. 1. LCONF_FORMAT_SCHEMA_STRICT

This is the default LCONF-Schema-Format and MUST be supported by all LCONF-Libraries.

Naming Convention

A LCONF_FORMAT_SCHEMA_STRICT LCONF-Key-Name (STRUCTURE_TABLE's LCONF-Column-Name are also considered to be LCONF-Key-Names):

MUST be a sequence of one or more (but maximum thirty-one '31') characters of these groups:

Additionally constraints:

7.1.2. LCONF_FORMAT_SCHEMA_FLEXIBLE

This LCONF-Schema-Format has fewer constraints but MAY NOT be supported by all LCONF-Libraries.

Naming Convention

A LCONF_FORMAT_SCHEMA_FLEXIBLE LCONF-Key-Name (STRUCTURE_TABLE's LCONF-Column-Name are also considered to be LCONF-Key-Names) is a sequence of one or more Unicode characters and is case-sensitive. It MUST NOT contain any LCONF_VERTICAL_LINE |.

7.2. Schema: IDENTIFIER Line

Each LCONF-Schema-Definition is a STRUCTURE_SINGLE_BLOCK where the Identifier-Line LCONF-Key-Name:

A LCONF-Schema-Identifier-Line MUST

Example LCONF-Schema Identifier-Lines

. Registered | STRUCTURE_PAIR

. Colors | STRUCTURE_LIST

. mobile_numbers | STRUCTURE_LIST (0,3)

. mobile_numbers | STRUCTURE_LIST (0,3)

. credit_cards | STRUCTURE_UNNAMED_BLOCKS (1,2)

Example of a corresponding LCONF-Section

Registered :: true

- Colors
    Blue
    Red

# minimum required list items 0, maximum allowed items 3
- mobile_numbers

# minimum required blocks 1, maximum allowed blocks 2
* credit_cards
    .
        issuing_network :: Visa
        card_number :: 4639588964759877

7.2.1. Additional Constraints

Some elements can have one additional constraint after the LCONF-Structure.

can set a minimum/maximum number of elements they require. (LCONF-Constrain-Min-Max)

A LCONF-Constrain-Min-Max MUST:

IMPORTANT: To not define one of the two constraints set it to TYPE_NOTSET (LCONF_NOTSET).

# minimum required list items 2, maximum allowed items 5
. MobileNumbers | STRUCTURE_LIST (2,5)

# minimum required table rows not restricted, maximum allowed required table rows 5
. interests | STRUCTURE_TABLE (NOTSET,5)

# minimum required blocks 1, maximum allowed blocks not restricted
. credit_cards | STRUCTURE_UNNAMED_BLOCKS (1,NOTSET)

7.3. Schema: ITEM Pair

This is required except STRUCTURE_SINGLE_BLOCK, STRUCTURE_NAMED_BLOCKS, STRUCTURE_UNNAMED_BLOCKS only use the LCONF-Schema Identifier-Line.

The Value for this pair is a LCONF-Item-Requirement-Option followed by a LCONF-Value-Type.

EXCEPTION: STRUCTURE_TABLE uses only the LCONF-Item-Requirement-Option because LCONF-Value-Types are set per Column.

A LCONF-Schema ITEM Pair MUST

Example LCONF-Schema ITEM Pair

. Colors | STRUCTURE_LIST
    ITEM :: OPTIONAL | TYPE_STRING

. Sex | STRUCTURE_PAIR
    ITEM :: REQUIRED | TYPE_STRING [Male, Female]

. ports | STRUCTURE_PAIR
    ITEM :: REQUIRED_NOT_EMPTY | TYPE_INTEGER [25,80,443]

. credit_card_number | STRUCTURE_PAIR
    ITEM :: OPTIONAL | TYPE_DIGITS (15,19)

. telephone_number | STRUCTURE_PAIR
    ITEM :: REQUIRED_NOT_EMPTY | TYPE_PATTERN_DIGITS (+@ @@@ @@@ @@@@)

. interest_rate | STRUCTURE_PAIR
    ITEM :: OPTIONAL | TYPE_FLOAT (0.5,<10.0)

. interest_rate2 | STRUCTURE_PAIR
    ITEM :: OPTIONAL | TYPE_FLOAT (>1.0,10.0)

Example of a corresponding LCONF-Section

Registered :: true

- Colors
    Blue
    Red

# predefined valid values one of `Male`,` Female`
Sex :: Female

# predefined valid values one of `25`, `80`, `443`
ports :: 80

# minimum required chars (digits) 15, maximum allowed  chars (digits) 19
credit_card_number :: 4639588964759877

# Pattern (+@ @@@ @@@ @@@@)
telephone_number :: +1 212 748 4496

# minimum required value 0.5, maximum allowed value less than 10.0
interest_rate :: 9.9999

# minimum required value greater than 1.0, maximum allowed value 10.0
interest_rate2 :: 10.0

7.3.1 LCONF-Item-Requirement-Option

EXCEPTION: STRUCTURE_TABLE uses only the Item-Requirement-Option because LCONF-Value-Types are set per Column.

7.3.2. Additional Constraints

Some elements can have one additional constraint after the LCONF-Value-Type.

7.3.1.1. List of Predefined Valid Values

For all LCONF-Value-Types one can define optional a list of predefined values (LCONF-Constrain-Predefined-Values).

A LCONF-Constrain-Predefined-Values MUST:

NOTE: LCONF_NOTSET and if an Empty-Value is valid is set in the LCONF-Item-Requirement-Option part.

. Sex | STRUCTURE_PAIR
    ITEM :: OPTIONAL | TYPE_STRING [Male, Female]

. Sex2 | STRUCTURE_PAIR
    ITEM :: REQUIRED | TYPE_STRING [Male, Female]

. ports | STRUCTURE_PAIR
    ITEM :: REQUIRED_NOT_EMPTY | TYPE_INTEGER [25,80,443]

Example of a corresponding LCONF-Section

# predefined valid values one of `Male`,` Female`
Sex :: Female

# predefined valid values one of `Male`,` Female`
#   can also be empty
Sex ::

# predefined valid values one of `25`, `80`, `443`
ports :: 80

7.3.1.2. Digits Pattern

For TYPE_PATTERN_DIGITS one MUST define either a list of predefined valid values (LCONF-Constrain-Predefined-Values) or a LCONF-Constrain-Digits-Pattern which MUST:

NOTE: LCONF_NOTSET and if an Empty-Value is valid is set in the LCONF-Item-Requirement-Option part.

Example LCONF-Schema ITEM Pair

. telephone_number | STRUCTURE_PAIR
    ITEM :: REQUIRED_NOT_EMPTY | TYPE_PATTERN_DIGITS (+@ @@@ @@@ @@@@)

Example of a corresponding LCONF-Section

# Pattern (+@ @@@ @@@ @@@@)
telephone_number :: +1 212 748 4496

7.3.1.3. LCONF-Constrain-Min-Max

TYPE_STRING, TYPE_DIGITS one MAY set a minimum/maximum LCONF-Constrain-Min-Max which MUST:

IMPORTANT: To not define one of the two constraints set it to TYPE_NOTSET (LCONF_NOTSET).

TYPE_STRING: the minimum is the number of required characters and the maximum allowed characters.

TYPE_DIGITS: the minimum is the number of required characters (digits) and the maximum allowed characters (digits).

Example LCONF-Schema ITEM Pair

. State | STRUCTURE_PAIR
    ITEM :: REQUIRED_NOT_EMPTY | TYPE_STRING (2,2)

. credit_card_number | STRUCTURE_PAIR
    ITEM :: OPTIONAL | TYPE_DIGITS (15,19)

Example of a corresponding LCONF-Section

# minimum required chars 2, maximum allowed chars 2
State :: NY

# minimum required chars (digits) 15, maximum allowed chars (digits) 19
credit_card_number :: 4639588964759877

For TYPE_INTEGER, TYPE_FLOAT and TYPE_NUMBER one MAY set a minimum/maximum LCONF-Constrain-Min-Max which MUST:

IMPORTANT: To not define one of the two constraints set it to TYPE_NOTSET (LCONF_NOTSET).

Example LCONF-Schema ITEM Pair

. ZIPCode | STRUCTURE_PAIR
    ITEM :: OPTIONAL | TYPE_INTEGER (10000,99999)

. interest_rate | STRUCTURE_PAIR
    ITEM :: OPTIONAL | TYPE_FLOAT (0.5,10.0)

. interest_rate2 | STRUCTURE_PAIR
    ITEM :: OPTIONAL | TYPE_NUMBER (>1,<10.0)

. moving_balance | STRUCTURE_PAIR
    ITEM :: OPTIONAL | TYPE_FLOAT (>-30000,NOTSET)

Example of a corresponding LCONF-Section

# minimum required value 10000, maximum allowed value 99999
ZIPCode :: 10022

# minimum required value 0.5, maximum allowed value 10.0
interest_rate :: 10.0

# minimum required value greater than 1, maximum allowed value less than 10.0
interest_rate2 :: 9.9999

# minimum required value greater than -30000, maximum allowed value not defined
moving_balance :: -29999.9999

7.4. Schema: DEFAULT & EMPTY_REPLACEMENT Pairs

DEFAULT and EMPTY_REPLACEMENT are optional items depending on the LCONF-STRUCTURE.

7.4.1. LCONF-Schema: STRUCTURE_PAIR

DEFAULT and EMPTY_REPLACEMENT are optional items.

If not set it is for both assumed:

Examples:

. registered1 | STRUCTURE_PAIR
    ITEM :: REQUIRED | TYPE_STRING
    DEFAULT ::
    EMPTY_REPLACEMENT ::

. registered2 | STRUCTURE_PAIR
    ITEM :: OPTIONAL | TYPE_BOOLEAN
    DEFAULT :: NOTSET
    EMPTY_REPLACEMENT :: NOTSET

# Set DEFAULT and EMPTY_REPLACEMENT
. registered3 | STRUCTURE_PAIR
    ITEM :: OPTIONAL | TYPE_BOOLEAN
    DEFAULT :: true
    EMPTY_REPLACEMENT :: false

7.4.2. LCONF-Schema: STRUCTURE_LIST

DEFAULT is an optional item and EMPTY_REPLACEMENT is not a STRUCTURE_LIST LCONF-Schema item.

If not set it is assumed an empty list (without any values - an empty sequence) LCONF_EMPTY_LIST: - DEFAULT

Examples:

. colors | STRUCTURE_LIST
    ITEM :: REQUIRED | TYPE_STRING
    - DEFAULT

# Set DEFAULT
. registered1 | STRUCTURE_LIST
    ITEM :: OPTIONAL | TYPE_STRING
    - DEFAULT
        Red,
        blue

# Set DEFAULT: Compact notation
. registered2 | STRUCTURE_LIST
    ITEM :: OPTIONAL | TYPE_STRING
    - DEFAULT :: Red, blue

7.4.3. LCONF-Schema: STRUCTURE_TABLE

DEFAULT is an optional item and EMPTY_REPLACEMENT is not a STRUCTURE_TABLE LCONF-Schema item.

If not set it is assumed a LCONF_EMPTY_TABLE (without any rows - an empty sequence): | DEFAULT

COLUMNS: This is required and only used for STRUCTURE_TABLE and is a STRUCTURE_LIST where each value line has the format of:

Column NAME | Column DEFAULT | Column EMPTY_REPLACEMENT | Column Value-REQUIRED | Column TYPE & any CONSTRAINTS

Leading and ending whitespace of individual parts is stripped.

Examples:

. favorite1s | STRUCTURE_TABLE
    ITEM :: OPTIONAL
    - COLUMNS
        # NAME   | DEFAULT | EMPTY_REPLACEMENT | Value-REQUIRED     | TYPE & any CONSTRAINTS
        # ------ | ------- | ----------------- | ------------------ | -----------------------
        food     |         |                   | REQUIRED_NOT_EMPTY | TYPE_STRING (NOTSET,25)
        sport    |         |                   | OPTIONAL           | TYPE_STRING
        color    |         |                   | OPTIONAL           | TYPE_STRING
        number   | NOTSET  | 0                 | OPTIONAL           | TYPE_INTEGER (>0,<100)

    | DEFAULT

. favorites2 | STRUCTURE_TABLE
    ITEM :: OPTIONAL
    - COLUMNS
        # NAME   | DEFAULT | EMPTY_REPLACEMENT | Value-REQUIRED     | TYPE & any CONSTRAINTS
        # ------ | ------- | ----------------- | ------------------ | -----------------------
        food     |         |                   | REQUIRED_NOT_EMPTY | TYPE_STRING (NOTSET,25)
        sport    |         |                   | OPTIONAL           | TYPE_STRING
        color    |         |                   | OPTIONAL           | TYPE_STRING
        number   | NOTSET  | 0                 | OPTIONAL           | TYPE_INTEGER (>0,<100)

    | DEFAULT
        / food          | sport          | color  | number |
        / ------------- | -------------- | ------ | ------ |
        | Stroganoff    | figure skating | violet | 0.0    |
        | Rice          | ballet         | orange | NOTSET |
        | French fries  |                |        |        |
        | Fried Chicken | NOTSET         |        | 89.9   |

7.5 LCONF-Schema-Comment-Lines

If a LCONF-Schema-Line first none whitespace character is a LCONF_SCHEMA_COMMENT_LINE_IDENTIFIER it is considered a LCONF-Schema-Comment-Line which are parsed. The purpose of such LCONF-Schema-Comment-Lines is to emit an example LCONF-Section with additional information.

NOTE: LCONF-Schema MAY also contain regular LCONF-Section-Comment-Line which are not parsed.

7.5.1 Auto-generated Comment-Lines

LCONF-Libraries MUST implement an option to auto-generate for each LCONF-Schema-Definition Comment-Lines which MUST contain info like:

NOTE STRUCTURE_TABLE needs to aut-generate also the COLUMNS info.

Example LCONF-Schema-Definition

. registered | STRUCTURE_PAIR
    ITEM :: OPTIONAL | TYPE_BOOLEAN
    DEFAULT :: true
    EMPTY_REPLACEMENT :: false

. interest_rate | STRUCTURE_PAIR
    ITEM :: REQUIRED | TYPE_FLOAT (0.5,10.0)

Example default output: The output format is not defined and are here just as an example.

# <registered> OPTIONAL | TYPE_BOOLEAN
#   Default: <true> | Empty-Default: <false>
registered :: true

# <interest_rate> REQUIRED | TYPE_FLOAT (0.5,10.0)
#   Default: <NOTSET> | Empty-Default: <NOTSET>
interest_rate :: NOTSET

7.5.1.1 STRUCTURE_TABLE

For STRUCTURE_TABLE the auto-generated LCONF-Schema-Comment-Lines MUST also include the Columns definitions.

Example LCONF-Schema-Definition

. favorites | STRUCTURE_TABLE
    ITEM :: OPTIONAL
    - COLUMNS
        # NAME   | DEFAULT | EMPTY_REPLACEMENT | Value-REQUIRED     | TYPE & any CONSTRAINTS
        # ------ | ------- | ----------------- | ------------------ | -----------------------
        food     |         |                   | REQUIRED_NOT_EMPTY | TYPE_STRING (NOTSET,25)
        sport    |         |                   | OPTIONAL           | TYPE_STRING
        color    |         |                   | OPTIONAL           | TYPE_STRING
        number   | NOTSET  | 0                 | OPTIONAL           | TYPE_INTEGER (>0,<100)

    | DEFAULT
        / food          | sport          | color  | number |
        / ------------- | -------------- | ------ | ------ |
        | Stroganoff    | figure skating | violet | 0.0    |
        | Rice          | ballet         | orange | NOTSET |
        | French fries  |                |        |        |
        | Fried Chicken | NOTSET         |        | 89.9   |

Example default output: The output format is not defined and are here just as an example.

# <favorites> OPTIONAL
# COLUMNS # NAME   | DEFAULT | EMPTY_REPLACEMENT | Value-REQUIRED     | TYPE & any CONSTRAINTS
#         # ------ | ------- | ----------------- | ------------------ | -----------------------
#         food     |         |                   | REQUIRED_NOT_EMPTY | TYPE_STRING (NOTSET,25)
#         sport    |         |                   | OPTIONAL           | TYPE_STRING
#         color    |         |                   | OPTIONAL           | TYPE_STRING
#         number   | NOTSET  | 0                 | OPTIONAL           | TYPE_INTEGER (>0,<100)
| DEFAULT
    # food          | sport          | color  | number |
    # ------------- | -------------- | ------ | ------ |
    | Stroganoff    | figure skating | violet | 0.0    |
    | Rice          | ballet         | orange | NOTSET |
    | French fries  |                |        |        |
    | Fried Chicken | NOTSET         |        | 89.9   |

7.5.2 LCONF-Section Comment Emit Options

Name Definition
EMIT_NO_COMMENTS No comments MUST be emitted.
EMIT_ONLY_MANUAL_COMMENTS Only manual LCONF-Schema-Comment-Lines MUST be emitted.
EMIT_ALL_COMMENTS Auto-generated and manual LCONF-Schema-Comment-Lines MUST be emitted.

7.6. LCONF-Libraries Schema Requirements