Heads up!
Added in Fzzy Config 0.6.0
Validation can be joined into pairs, which are stored as a ValidatedPair.Tuple
. This allows you to present two settings as one, that the user understands are part of the same "unit" of functionality. For example:
- A range with a max and min. Join these together to create one "range" setting that has both two selectors side by side.
- An on-off switch and then an Object/
ValidatedAny
setting with the switch as a condition, building a "confirmation gate" where the user first has to enable the setting before they can interact with it.
Other features:
- Pairs can have labels added to better illustrate what each half of the pair is accomplishing. "Min" and "Max" for the above range example.
- Pair elements can also be stacked on top of each other. See the constructor method below using
ValidatedPair.LayoutStyle.STACKED
.
//Validated field has a mapping method 'pairWith' that automatically applies the default values of each half into the Pairs default valuepublic ValidatedPair<Int, Int> pair1 = (new ValidatedInt(1, 10, 0)).pairWith(new ValidatedInt(10, 20, 10));//you can still do it the other way if you want. This also lets you stack the two settings on top of each other if desired.public ValidatedPair<Int, Int> pair1Long = new ValidatedPair(new ValidatedPair.Tuple(1, 10), new ValidatedInt(1, 10, 0), new ValidatedInt(10, 20, 10), ValidatedPair.LayoutStyle.STACKED);//if both halves are the same validation type, there is a shorthand static method. You can define the default tuple and layout style optionally.public ValidatedPair<Int, Int> pairSame = ValidatedPair.of(new ValidatedInt(1));//if both halves are the same validation type, there is a shorthand static method. You can define the default tuple and layout style optionally.public ValidatedPair<Int, Int> pairSameLabeled = ValidatedPair.withLabels(ValidatedPair.of(new ValidatedInt(1)), LeftText, RightText);//Pairs store their value in a nested class `Tuple`. To retrieve your setting you would do something likeint pairMin = pair1.get().left;int pairMax = pair1.get().right;
Heads up!
See the documentation page here 🗗