mbdlyb_ui.validation

Copyright (c) 2023 - 2026 TNO-ESI All rights reserved.

Functions

base_name_validation(context[, element, allow_empty])

Build NiceGUI validators for a name within a network or root node class.

valid_name(→ bool)

Check that a name contains only ASCII letters, digits, underscores, or hyphens.

Module Contents

mbdlyb_ui.validation.base_name_validation(context: mbdlyb.gdb.GMBDNet | type[mbdlyb.gdb.GMBDNet], element: mbdlyb.gdb.GMBDElement | None = None, allow_empty: bool = False)

Build NiceGUI validators for a name within a network or root node class.

Parameters:
  • context – Network whose children must have distinct names, or root node class.

  • element – Existing element to exclude when checking duplicate names.

  • allow_empty – Whether an empty name is permitted.

Returns:

A mapping of error messages to name-checking callables.

mbdlyb_ui.validation.valid_name(s: str) → bool

Check that a name contains only ASCII letters, digits, underscores, or hyphens.

Parameters:

s – Proposed name.

Returns:

Whether all characters in the name are allowed.