Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatRule ¶ added in v0.5.2
FormatRule renders a Rule back into the human-readable rule syntax shown in the CLI, e.g. "type=Video && size>1GB -> Videos/Large".
Round trip: for a rule whose Conditions are populated, ParseRule(FormatRule(r), 0) yields the same Conditions and Destination, except for two limitations inherited from ParseRule. It reads a left-hand side free of '=', '>', '<' and '&&' as a bare glob, so a rule whose only clause uses a word operator does not survive. And mapField has no 'mod_time' case, so a rule using models.FieldModTime renders to text ParseRule rejects outright. Rules built from the preset helper fields (Type, Extensions, MinSize, MaxSize) fall back to rendering those helpers as clauses, which is display-only and deliberately lossy — the rendered string parses, but not back into the helpers.
func ParseRule ¶
ParseRule parses CLI rule string e.g.: "type=video && size>1GB -> Videos/Large" "name=~'^IMG_' -> Camera" "*.mp4 -> Videos" "size>500MB -> Huge"
func ValidateRule ¶ added in v0.7.0
ValidateRule reports every problem that makes a rule evaluate incorrectly: unparseable helper sizes, unknown fields, operators a field does not support, unparseable size values and regexes that do not compile. A nil result means the rule is safe to evaluate.
func ValidateRules ¶ added in v0.7.0
ValidateRules aggregates the problems of every rule, preserving rule order.