You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Quarkus we use Smallrye Config and @ConfigMapping for framework configuration.
This works great, but in that context we can't require additional dependencies (such as Jakarta Bean Validation and implementation), since that would force every single Quarkus application to depend on that.
Feature
It would be nice to provide some very simple validation annotations for such situation. We don't need a full-blown validation framework, just some simple validations: ranges for comparables types (integers, ...), maybe patterns for some edge cases (though those could be handled with a custom converter).
Implementation idea
The backing converter wrappers are already available in Smallrye Config:
One possibility would be to provide annotations such as these:
public @interface WithMin {
Stringvalue();
// Maybe... Jakarta Validation itself doesn't provide the option,// so we could just assume everything is inclusive too.booleaninclusivedefaulttrue;
// Defaults to natural order for types implementing Comparable,// but might require customization for other types?Class<? extendsComparator<?>> comparator() defaultComparableComparator.class;
}
public @interface WithMax {
Stringvalue();
booleaninclusive() defaulttrue;
Class<? extendsComparator<?>> comparator() defaultComparableComparator.class;
}
public @interface WithRange {
Stringmin();
booleanminInclusive() defaulttrue;
Stringmax();
booleanmaxInclusive() defaulttrue;
Class<? extendsComparator<?>> comparator() defaultComparableComparator.class;
}
// Maybe... like I mentioned above, this would be much less usefulpublic @interface WithPattern {
Stringregexp();
}
The text was updated successfully, but these errors were encountered:
yrodiere
changed the title
Simple validation annotations that don't rely on Jakarta Validation
Simple validation annotations that don't rely on Jakarta Bean Validation
Sep 22, 2023
An important feature of this proposal, and an important limitation of using the BV annotations, is that by giving our min/max values as a string, we can apply the same converter to the min/max values to ensure that we support any min/max values.
+1 to allowing a custom comparator for the comparison, +1 to this proposal overall.
Use case
In Quarkus we use Smallrye Config and
@ConfigMapping
for framework configuration.This works great, but in that context we can't require additional dependencies (such as Jakarta Bean Validation and implementation), since that would force every single Quarkus application to depend on that.
Feature
It would be nice to provide some very simple validation annotations for such situation. We don't need a full-blown validation framework, just some simple validations: ranges for comparables types (integers, ...), maybe patterns for some edge cases (though those could be handled with a custom converter).
Implementation idea
The backing converter wrappers are already available in Smallrye Config:
smallrye-config/implementation/src/main/java/io/smallrye/config/Converters.java
Lines 410 to 624 in b084300
One possibility would be to provide annotations such as these:
The text was updated successfully, but these errors were encountered: