Releases: mlykotom/valifi
Form of forms + bugfix
Form of forms
- you can now create form containing other form!
- useful when having some multi-step UI and want to validate each part separately, but overall as well.
- you can mix form with fields
Usage:
public class MyViewModel extends ViewModel {
public final field1 = ValiFieldText();
public final field2 = ValiFieldText();
public final subForm = ValiFiForm(field1, field2);
public final field3 = ValiFieldText();
// you can even mix form with fields (e.g. some "accept terms" checkbox?)
public final overallForm = ValiFiForm(subForm, field3);
}
Bug fixes
- fixed a bug, when
field
wouldn't beisValid()
when belonging to a form in databinding (form.valid
would be called properly, butfield.valid
wouldn't)
Migration to androidx!
Since this release, the library uses androidx
instead of android support dependency.
Please, if you need android.support
, refer to older versions of the library.
Changelog:
- support lib updated to 28.0 (= androidx 1.0)
- updated gradle build files
Add global validation, setting temporal error, manual validation
- Add global validator which may be used instead of existing email, phone, etc. validators
- Field now may set custom error (e.g. message from network) which doesn't change validation and will be replaced with validation error when input changes
- manual triggering of validation possible
Field is changed in construction flag
Add constructor which makes possible to set default value without marking the field as changed (and thus not validating it in construction). This is useful e.g. when loading data from network and wanting the field to be clear, but "invalid". This is backwards compatible - only new constructor added.
Fixes testability
Removes protected method getContext()
which made testing impossible because specific validators were using string resources as errors.
If you used getContext().getString()
in your custom fields, you may use getString()
method which for tests returns "string-[resource-id]".
Also there are new install()
methods for tests (don't need Context
).
Adds remove validator
Provides methods:
removeValidator()
removeAsyncValidator()
which may remove validator and keep the field without reset.
Adds reset()
Adds reset()
method on field or form which is useful e.g. after submit of form.
The role is to clear the field and be able to use it again from scratch.
Adds ValiFiValidable interface
Updates IValidable so that it can have destroy() method.
Adds getting/setting number value
1.1.1 Adds getter and setter for number type
Credit Cards, Numbers and Async validation
Adds new API
- ValiFieldCard for validating credit cards
- ValiFieldNumber for validating numbers (Long, Int, Double and Float are implemented)
- Adds asynchronous validation which may be lasting longer and blocking UI