validate method
Validates the given input string as text according to the config.
Implementation
Either<TextError, String> validate(String input) {
final vConfig = v.TextValidationConfig(
allowEmpty: config.allowEmpty,
allowOnlyWhitespace: config.allowOnlyWhitespace,
trimWhitespace: config.trimWhitespace,
minLength: config.minLength,
maxLength: config.maxLength,
pattern: config.pattern != null ? RegExp(config.pattern!) : null,
allowedCharacters: config.allowedCharacters,
blacklistedWords: config.blacklistedWords,
wholeWordBlacklist: config.wholeWordBlacklist,
);
return v.TextValidator(vConfig)
.validate(input)
.fold(
(issue) => Left(
issue is v.TextInvalidPatternIssue
? TextInvalidPattern(config.pattern ?? '')
: issue.toTextError(),
),
Right.new,
);
}