Skip to content

Validation API

Tier: Stable Core

Nickname/comment/initial-value validators and system nickname constants.

pyclickplc.SYSTEM_NICKNAME_TYPES module-attribute

SYSTEM_NICKNAME_TYPES: frozenset[str] = frozenset(
    {"SC", "SD", "X"}
)

pyclickplc.validate_nickname

validate_nickname(
    nickname: str, *, system_bank: str | None = None
) -> tuple[bool, str]

Validate nickname format (length, characters, reserved words).

Does NOT check uniqueness -- that is application-specific.

Parameters:

Name Type Description Default
nickname str

The nickname to validate

required
system_bank str | None

Optional system bank context: - "SC"/"SD": allows PLC system punctuation - "X": allows only _IO... style system names - None: standard user nickname rules

None

Returns:

Type Description
tuple[bool, str]

Tuple of (is_valid, error_message) - error_message is "" if valid

pyclickplc.validate_comment

validate_comment(comment: str) -> tuple[bool, str]

Validate comment length.

Does NOT check block tag uniqueness -- that requires blocks.py context.

Parameters:

Name Type Description Default
comment str

The comment to validate

required

Returns:

Type Description
tuple[bool, str]

Tuple of (is_valid, error_message) - error_message is "" if valid

pyclickplc.validate_initial_value

validate_initial_value(
    initial_value: str, data_type: int
) -> tuple[bool, str]

Validate an initial value against the data type rules.

Parameters:

Name Type Description Default
initial_value str

The initial value string to validate

required
data_type int

The DataType number (0=bit, 1=int, 2=int2, 3=float, 4=hex, 6=txt)

required

Returns:

Type Description
tuple[bool, str]

Tuple of (is_valid, error_message) - error_message is "" if valid