stringNotContains function

Validator stringNotContains(
  1. String substring
)

Validates that the String does not contain substring

This validator also validates that the value is a String first So there's no need to add the isTypeString validator when using this validator

Implementation

Validator stringNotContains(String substring) {
  return (value) {
    final isListResult = isType<String>().call(value);
    if (isListResult.isNotValid) return isListResult;

    return Result(
      isValid: !(value as String).contains(substring),
      expected: 'String to not contain "$substring"',
      value: value,
    );
  };
}