Stay organized with collections
Save and categorize content based on your preferences.
Validator
interface Validator
This interface is used to make sure that the text entered in this TextView complies to a certain format. Since there is no foolproof way to prevent the user from leaving this View with an incorrect value in it, all we can do is try to fix it ourselves when this happens.
Summary
Public methods |
abstract CharSequence! |
Corrects the specified text to make it valid.
|
abstract Boolean |
Validates the specified text.
|
Public methods
fixText
abstract fun fixText(invalidText: CharSequence!): CharSequence!
Corrects the specified text to make it valid.
Parameters |
invalidText |
CharSequence!: A string that doesn't pass validation: isValid(invalidText) returns false |
Return |
CharSequence! |
A string based on invalidText such as invoking isValid() on it returns true. |
isValid
abstract fun isValid(text: CharSequence!): Boolean
Validates the specified text.
Return |
Boolean |
true If the text currently in the text editor is valid. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# AutoCompleteTextView.Validator\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nValidator\n=========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/widget/AutoCompleteTextView.Validator \"View this page in Java\") \n\n```\ninterface Validator\n```\n\n|----------------------------------------------------|\n| [android.widget.AutoCompleteTextView.Validator](#) |\n\nThis interface is used to make sure that the text entered in this TextView complies to a certain format. Since there is no foolproof way to prevent the user from leaving this View with an incorrect value in it, all we can do is try to fix it ourselves when this happens.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)! | [fixText](#fixText(kotlin.CharSequence))`(`invalidText:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`)` Corrects the specified text to make it valid. |\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isValid](#isValid(kotlin.CharSequence))`(`text:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`)` Validates the specified text. |\n\nPublic methods\n--------------\n\n### fixText\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun fixText(invalidText: CharSequence!): CharSequence!\n```\n\nCorrects the specified text to make it valid.\n\n| Parameters ||\n|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `invalidText` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!: A string that doesn't pass validation: isValid(invalidText) returns false |\n\n| Return ||\n|------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|\n| [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)! | A string based on invalidText such as invoking isValid() on it returns true. |\n\n**See Also**\n\n- [#isValid(CharSequence)](#isValid(kotlin.CharSequence)) \n\n### isValid\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun isValid(text: CharSequence!): Boolean\n```\n\nValidates the specified text.\n\n| Return ||\n|------------------------------------------------------------------------------------|---------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true If the text currently in the text editor is valid. |\n\n**See Also**\n\n- [#fixText(CharSequence)](#fixText(kotlin.CharSequence))"]]