lawyer 0.2.0 copy "lawyer: ^0.2.0" to clipboard
lawyer: ^0.2.0 copied to clipboard

A lightweight, dependency-free rule engine for Dart and Flutter. Define ordered allow/deny rules with wildcards and dimensions, then check conditions.

0.2.0 #

Breaking changes, see the migration guide.

  • Renamed Action to RuleAction, which no longer clashes with Flutter's Action class.
  • Replaced the Lawyer.instance singleton, setRules and setDimensions with an immutable Lawyer(rules: ..., dimensions: ...).
  • Rule now takes typed Criterions (Criterion.any, Criterion.exact, Criterion.oneOf); Rule.from keeps the untyped shorthand. Added Rule.allow and Rule.deny.
  • Dimension now describes a single position; pass one per position.
  • Every condition is validated against its dimension, and rules are validated against the dimensions when the Lawyer is created.
  • An empty rule list denies everything instead of throwing; empty conditions throw an ArgumentError.
  • Removed the Flutter dependency; this is now a pure Dart package.

Fixes

  • Strings were matched as substrings ('Gold' matched 'Gold member', and '' matched anything).
  • Repeated elements in a rule, such as two wildcards, were checked at the wrong position.
  • Rules longer than the dimensions threw a RangeError, and unsupported rule elements threw a NoSuchMethodError during check.

Other

  • Added Lawyer.matchingRule to explain a decision, and Rule.matches.
  • Added ==, hashCode and toString to Rule, Criterion and Dimension.
  • Added API documentation, a complete README and many more tests.
  • Added CI.

0.1.2 #

  • Version bump only.

0.1.1 #

  • Updated the package description and README.

0.1.0 #

  • Added the repository link.

0.0.1 #

  • Initial release.
7
likes
160
points
75
downloads

Documentation

API reference

Publisher

verified publisherenver.dev

Weekly Downloads

A lightweight, dependency-free rule engine for Dart and Flutter. Define ordered allow/deny rules with wildcards and dimensions, then check conditions.

Repository (GitHub)
View/report issues

Topics

#rules #rule-engine #permissions #validation #business-logic

License

MIT (license)

More

Packages that depend on lawyer