commit | 2722e36e5591398cdf96be94639fe9ccc055a3d6 | [log] [tgz] |
---|---|---|
author | mrenouf <mrenouf@google.com> | Fri Dec 01 13:47:36 2023 -0500 |
committer | Mark Renouf <mrenouf@google.com> | Thu Dec 07 22:18:37 2023 +0000 |
tree | fa68944754e88edbdab8e40cafb343b598c3b26f | |
parent | c85c6c55ebdeef744cb812b74fed30cd2b8a4d49 [diff] |
Validation framework This pattern grew out of existing Intent data extraction code. Goals * abstract away the details of processing * provide informative errors and warnings * self documenting usage * able to report multiple findings (warnings) * fail assertions in acontrolled manner, not by throwing Sample usage: ``` fun readArgs( val bundle: Bundle ) = validateFrom(bundle::get): ValidationResult<ExampleObject> { val intValue = required(value<Int>("KEY_1")) val stringValue = required(value<String>("KEY_2")) val arrayValue = optional(array<String>("KEY_3")) val doubleValue = optional(value<Double>("KEY_4")) ExampleObject(intValue, stringValue, arrayValue, doubleValue) } ``` Bug: 300157408 Test: atest com.android.intentresolver.validation Change-Id: I517e70df84c28e42023f19c8616804bc46884b49
IntentResolver
provides the implementation for Intent ACTION_CHOOSER
See also: ShareCompat.IntentBuilder