case class Prop[T, S](label: String = "", actual: Property[T] = Property[T](), expected: Property[S] = Property[S](), constraint: (T, S) => Result = Prop.checkProp, decorator: Decorator = Decorator().bkGreyLabel) extends Executable with DecoratedProperty[Prop[T, S]] with Product with Serializable
The Prop class is a named property which holds:
- an actual value
- an expected value
- a constraint to check if the actual value conforms to the expected one
This property can be executed and can be inserted in a Form.
A Prop is meant to be declared as "bound" to an actual value:
val customerName = Prop("Customer name", person.name)
[the actual value is not evaluated until the Prop is executed]
Then it can be associated an expected value with the apply method (usually in a Form declaration):
customerName("Bill")
The actual and the expected values can have different types and the constraint which is applied to them can be anything returning a result.
However the Prop companion object provides a method to create a Property with a constraint using a beEqualTo matcher:
Prop("Name", "Eric")("Eric") must_== Success("'Eric' is equal to 'Eric'")
- Alphabetic
- By Inheritance
- Prop
- Serializable
- Product
- Equals
- DecoratedProperty
- DecoratedLabel
- Executable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Prop(label: String = "", actual: Property[T] = Property[T](), expected: Property[S] = Property[S](), constraint: (T, S) => Result = Prop.checkProp, decorator: Decorator = Decorator().bkGreyLabel)
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val actual: Property[T]
- lazy val actualValue: Either[Result, T]
- returns
the actual value as either Right(value) or Left(result)
- def apply(e: => S): Prop[T, S]
The apply method sets the expected value and returns the Prop
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- val constraint: (T, S) => Result
- def decorateLabel(ns: Any): Any
do the decoration
do the decoration
- Definition Classes
- DecoratedLabel
- def decorateLabelWith(f: (Any) => Any): Prop[T, S]
set a new Decorator for the label
set a new Decorator for the label
- Definition Classes
- DecoratedLabel
- def decorateValue(ns: Any): Any
do the decoration
do the decoration
- Definition Classes
- DecoratedProperty
- def decorateValueWith(f: (Any) => Any): Prop[T, S]
set a new Decorator for the value
set a new Decorator for the value
- Definition Classes
- DecoratedProperty
- def decorateWith(f: (Any) => Any): Prop[T, S]
set a new Decorator
set a new Decorator
- Definition Classes
- DecoratedProperty
- val decorator: Decorator
- Definition Classes
- Prop → DecoratedLabel
- def decoratorIs(d: Decorator): Prop[T, S]
set a new Decorator
set a new Decorator
- Definition Classes
- Prop → DecoratedLabel
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(other: Any): Boolean
- Definition Classes
- Prop → Equals → AnyRef → Any
- def execute: Result
execute the constraint set on this property, with the expected value
execute the constraint set on this property, with the expected value
- Definition Classes
- Prop → Executable
- val expected: Property[S]
- lazy val expectedValue: Either[Result, S]
- returns
the expected value as an option
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- Prop → AnyRef → Any
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val label: String
- def labelStyles: String
return the label styles
return the label styles
- Definition Classes
- DecoratedLabel
- def map(f: (Result) => Result): Executable
- Definition Classes
- Executable
- def matchWith(c: (T, S) => Result): Prop[T, S]
set a specific constraint between the actual and expected value
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def resultIs(r: => Result): Prop[T, S]
set a specific result on the property
- def styleLabelWith(s: (String, String)): Prop[T, S]
set a new style for the label
set a new style for the label
- Definition Classes
- DecoratedLabel
- def styleValueWith(s: (String, String)): Prop[T, S]
set a new style for the value
set a new style for the value
- Definition Classes
- DecoratedProperty
- def styleWith(s: (String, String)): Prop[T, S]
set a new style
set a new style
- Definition Classes
- DecoratedProperty
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
Display the property:
Display the property:
label: "this" (actual: "that")
- Definition Classes
- Prop → AnyRef → Any
- def valueStyles: String
- Definition Classes
- DecoratedProperty
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)