Skip to content

Commit

Permalink
feat: add int type for validation values
Browse files Browse the repository at this point in the history
  • Loading branch information
MohiuddinM committed Oct 11, 2024
1 parent 309ecb2 commit 0bab636
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,15 @@ String _validateMethod(String className, List<UniversalType> types) {
String? _validationString(UniversalType type) {
final sb = StringBuffer();
if (type.min != null) {
sb.write(' static const double ${type.name}Min = ${type.min};\n');
final numType = type.type == 'integer' ? int : double;
final min = numType == int ? type.min?.toInt() : type.min;
sb.write(' static const $numType ${type.name}Min = $min;\n');
}

if (type.max != null) {
sb.write(' static const double ${type.name}Max = ${type.max};\n');
final numType = type.type == 'integer' ? int : double;
final max = numType == int ? type.max?.toInt() : type.max;
sb.write(' static const $numType ${type.name}Max = $max;\n');
}

if (type.minItems != null) {
Expand Down

0 comments on commit 0bab636

Please sign in to comment.