Skip to content

StringNode

Base classes

Name Children Inherits
NodeBase
promptantic.form.nodes
Common to all nodes.

⋔ Inheritance diagram

graph TD
  2799712588["nodes.StringNode"]
  1324256109["nodes.NodeBase"]
  2751680898["builtins.object"]
  1324256109 --> 2799712588
  2751680898 --> 1324256109

🛈 DocStrings

Bases: NodeBase

Free text, optionally constrained.

Source code in src/promptantic/form/nodes.py
@dataclass(frozen=True)
class StringNode(NodeBase):
    """Free text, optionally constrained."""

    kind: Literal["string"] = "string"
    format: str | None = None
    """``date``, ``date-time``, ``email``, ``uri``, ``uuid``, ... (JSON Schema formats)."""
    min_length: int | None = None
    max_length: int | None = None
    pattern: str | None = None
    content_media_type: str | None = None

    @property
    def secret(self) -> bool:
        """Input that shouldn't be shown (``format: password`` or ``writeOnly``)."""
        return self.format == "password" or self.meta.write_only

format class-attribute instance-attribute

format: str | None = None

date, date-time, email, uri, uuid, ... (JSON Schema formats).

secret property

secret: bool

Input that shouldn't be shown (format: password or writeOnly).

:fa-brands-github: Show source on GitHub