validation_chain 0.0.2 validation_chain: ^0.0.2 copied to clipboard
Validation Chain API.
Validation Chain #
A validation chain api to use with TextFormField
or Backend applicaitons made with dart. #
Usage #
import 'package:validation_chain/validation_chain.dart';
String? compulsory(String value) {
return value.isEmpty ? 'Required' : null;
}
String? tooShort(String value) {
return value.length < 5 ? 'Too Short' : null;
}
String? tooLong(String value) {
return value.length > 10 ? 'Too Long' : null;
}
final validationChain = ValidationChain([
compulsory,
tooShort,
tooLong,
]);
validationChain.validate(''); // 'Required'
validationChain.validate('Hey'); // 'Too Short'
validationChain.validate('Hello'); // null
validationChain.validate('Hello World'); // 'Too Long'