and method

LoStatus and(
  1. LoStatus other
)

Behaves like the logical and operator but for LoStatus to accumulate field statuses to compute the form status.

A B Result
invalid any invalid
pure pure pure
valid valid valid
pure valid mixed
valid pure mixed

Implementation

LoStatus and(LoStatus other) {
  if (isInvalid || other.isInvalid) return LoStatus.invalid;
  if (isPure && other.isPure) return LoStatus.pure;
  if (isValid && other.isValid) return LoStatus.valid;
  return LoStatus.mixed;
}