$darkmode
Elektra 0.11.0
Plugin: length

Length Validation

Introduction

This plugins purpose is to check the maximum length of strings. For example if check/length/max is set to 3, Strings with more than 3 characters will not validate (e.g. "abcd"), whereas "abc" would validate.

Installation

See installation. The package is called libelektra5-experimental.

Usage

# Mount `length` plugin to cascading namespace `/tests/length`
kdb mount config.dump /tests/length length
# Check the validity of the string stored in `/tests/length/text`
kdb meta-set spec:/tests/length/text check/length/max 3
# Try to set a longer string
kdb set user:/tests/length/text abcd
# STDERR: .*Validation Semantic.*
# ERROR: C03200
# RET: 5
# Set a correct string
kdb set user:/tests/length/text abc
kdb get user:/tests/length/text
# Undo modifications to the database
kdb rm -rf /tests/length
kdb umount /tests/length

Limitations

The plugin only checks that strings are not longer than a given number. It is not possible to set a minimum length.