tui.validate.rule
tui.validate.rule page|element|end FN
Registers a custom check.
Parameters
page:FNruns once before a page is walked.element:FNruns for every element, withTUI_V_FILE,TUI_V_LINE,TUI_V_COL,TUI_V_TAG,TUI_V_RAW,TUI_V_SELFCLOSE,TUI_V_DEPTH,TUI_V_PARENT_TAG,TUI_V_PARENT_ID,TUI_V_PARENT_SPLIT,TUI_V_GRANDPARENT_SPLITset. Read attributes withtui.validate.attr.end:FNruns after the walk, withTUI_V_PAGEand the mapsTUI_V_PANES,TUI_V_PANE_SPLIT,TUI_V_WIDGETS,TUI_V_WIDGET_PANE,TUI_V_WIDGET_PANE_AT(locations arefile|line|col).
Returns: 1 for another kind.
Notes
- Report with
tui.validate.error/tui.validate.warn. - Register rules after sourcing
tui.shand beforetui.start. - A clean validation is remembered per page set and file mtimes. After adding a rule, pages that already passed are not checked again until a page or include changes; delete
$TUI_HOME/cache/validated(or rundabt clear-cache) to force it.
Example
no_empty_title() {
[[ "$TUI_V_TAG" == pane ]] || return 0
tui.validate.attr title && [[ -z "$REPLY" ]] && tui.validate.warn "empty title" title
return 0
}
tui.validate.rule element no_empty_title
