lawyer 0.2.0
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
ActiontoRuleAction, which no longer clashes with Flutter'sActionclass. - Replaced the
Lawyer.instancesingleton,setRulesandsetDimensionswith an immutableLawyer(rules: ..., dimensions: ...). Rulenow takes typedCriterions (Criterion.any,Criterion.exact,Criterion.oneOf);Rule.fromkeeps the untyped shorthand. AddedRule.allowandRule.deny.Dimensionnow describes a single position; pass one per position.- Every condition is validated against its dimension, and rules are validated
against the dimensions when the
Lawyeris 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 aNoSuchMethodErrorduringcheck.
Other
- Added
Lawyer.matchingRuleto explain a decision, andRule.matches. - Added
==,hashCodeandtoStringtoRule,CriterionandDimension. - 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.