Attributes
- Companion:
- object
- Graph
- Supertypes
- trait Serializableclass Objecttrait Matchableclass Any
Members list
Value members
Abstract methods
Contravariant version of the map.
Contravariant version of the map.
Given a large class with nested case class for example. In order to test a single rule without stud all useless data you may want to create a rule for the specific type and not for the whole class.
class Region(value: String) extends AnyVal
class Citizenship(region: Region)
class User(name: String, age: Int, citizenship: Citizenship)
val checkRegionIsUK: Rule[Region] = Rule("Check region is UK").check {
case Region("UK") => Allow.withoutReasons
case Region(value) => Deny.because(s"Only UK region is accepted! Actual value: $$value")
}
In this case if you want to apply this rule to a User
instance con can use the contramap
method.
val checkUser: Rule[User] = checkRegionIsUK.contramap(_.citizenship.region)
NOTE: using generic
module, with import erules.generic.implicits.*
you can use
contramapTarget
to both contramap and add target information.
Attributes
Lift a pure, side-effect free rule with effect Id[_]
to specified G[_]
. Value is lifted as
a pure effect using Applicative
Lift a pure, side-effect free rule with effect Id[_]
to specified G[_]
. Value is lifted as
a pure effect using Applicative
Attributes
- G
Effect
- Returns:
A lifted rule to specifed effect type
G
Same as eval
but has only the RuleVerdict
value
Same as eval
but has only the RuleVerdict
value
Attributes
In this case if you want to apply this rule to a User
instance con can use the contramap
method.
- Given a large class with nested case class for example. In order to test a single rule without stud all useless data you may want to create a rule for the specific type and not for the whole class.
class Region(value: String) extends AnyVal
class Citizenship(region: Region)
class User(name: String, age: Int, citizenship: Citizenship)
val checkRegionIsUK: Rule[Region] = Rule("Check region is UK").check {
case Region("UK") => Allow.withoutReasons
case Region(value) => Deny.because(s"Only UK region is accepted! Actual value: $$value")
}
In this case if you want to apply this rule to a User
instance con can use the contramap
method.
val checkUser: Rule[User] = checkRegionIsUK.contramap(_.citizenship.region)
But dosing this if you want to keep the information that this rule doesn't check the whole
User
instance but just a small sub-set of the data you can use targetInfo
method to add
this information to this rule.
The typical value of this method is "string" version of the contramap parameter.
val checkUser: Rule[User] = checkRegionIsUK
.contramap(_.citizenship.region)
.targetInfo("citizenship.region")
NOTE: using generic
module, with import erules.generic.implicits.*
you can use
contramapTarget
to both contramap and add target information.
Attributes
Concrete methods
Compares the receiver object (this
) with the argument object (that
) for equivalence.
Compares the receiver object (this
) with the argument object (that
) for equivalence.
Any implementation of this method should be an equivalence relation:
- It is reflexive: for any instance
x
of typeAny
,x.equals(x)
should returntrue
. - It is symmetric: for any instances
x
andy
of typeAny
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any instances
x
,y
, andz
of typeAny
ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
.
If you override this method, you should verify that your implementation remains an equivalence relation.
Additionally, when overriding this method it is usually necessary to override hashCode
to ensure that
objects which are "equal" (o1.equals(o2)
returns true
) hash to the same scala.Int.
(o1.hashCode.equals(o2.hashCode)
).
Attributes
- that
the object to compare against this object for equality.
- Returns:
true
if the receiver object is equivalent to the argument;false
otherwise.- Definition Classes
- Any
Eval this rules. The evaluations result is stored into a 'Either[Throwable, T]', so the
ApplicativeError
doesn't raise error in case of failed rule evaluation
Eval this rules. The evaluations result is stored into a 'Either[Throwable, T]', so the
ApplicativeError
doesn't raise error in case of failed rule evaluation
Attributes
A full description of the rule, that contains name, description and target info where defined.
A full description of the rule, that contains name, description and target info where defined.
Attributes
Abstract fields
A string to add more information to this rule.
A string to add more information to this rule.
Attributes
A string to describe in summary this rule.
A string to describe in summary this rule.
Attributes
A string to describe what/who is the target of this rule.
A string to describe what/who is the target of this rule.