Skip to content
Playground(another site)

bynk.types.predicate_base_mismatch

Error A predicate does not apply to the type's base (e.g. a string predicate on an Int).

Each predicate checks one kind of value, so it can only refine a base that has such values. NonEmpty, MinLength, MaxLength, Length, Matches and IsoDate apply to a String, and NonNegative, Positive and InRange to an Int, Float or Decimal. A mismatch would test something the base cannot have. Change the base type to suit the predicate, or choose the predicate that suits the base.

Example

type Code = Int where NonEmpty // ✗ `NonEmpty` is a `String` predicate
type Code = String where NonEmpty // ✓

In the Book

See also

  • The grammar rule it governs: refinement.
  • Every code in its category, Type checking, on the diagnostic index.
  • bynk explain bynk.types.predicate_base_mismatch shows the same from the installed toolchain, without a network.