split function

IValidator split(
  1. String separator,
  2. IValidator child, {
  3. String? message,
})

Splits a string into a list of substrings.

Splits the input string at each occurrence of the separator. Fails if the input value is not a string. Passes the resulting list of strings to the child validator.

Example: split(',', listEach(toInt(isGte(0))))

Implementation

IValidator split(String separator, IValidator child, {String? message}) {
  final base = isString() & core.transform((v) => v.split(separator), child);
  return core.handleReturnPreserveValue(base, message);
}