when<_T> method

_T when<_T>({
  1. required _T string(
    1. ValidaString
    ),
  2. required _T num(
    1. ValidaNum
    ),
  3. required _T date(
    1. ValidaDate
    ),
  4. required _T duration(
    1. ValidaDuration
    ),
  5. required _T list(
    1. ValidaList
    ),
  6. required _T map(
    1. ValidaMap
    ),
  7. required _T set(
    1. ValidaSet
    ),
})

Implementation

_T when<_T>({
  required _T Function(ValidaString) string,
  required _T Function(ValidaNum) num,
  required _T Function(ValidaDate) date,
  required _T Function(ValidaDuration) duration,
  required _T Function(ValidaList) list,
  required _T Function(ValidaMap) map,
  required _T Function(ValidaSet) set,
}) {
  switch (variantType) {
    case ValidaFieldType.string:
      return string(this as ValidaString);
    case ValidaFieldType.num:
      return num(this as ValidaNum);
    case ValidaFieldType.date:
      return date(this as ValidaDate);
    case ValidaFieldType.duration:
      return duration(this as ValidaDuration);
    case ValidaFieldType.list:
      return list(this as ValidaList);
    case ValidaFieldType.map:
      return map(this as ValidaMap);
    case ValidaFieldType.set:
      return set(this as ValidaSet);
  }
}