My task is to show error when user click submit (if there is one).
For that I have :
data class ValidationResults(
val successful: Boolean,
val errorMessage: String? = null
)
Example of input mistake:
@Singleton
class ValidateUsername @Inject constructor() {
fun execute (username: String) : ValidationResults{
if(username.isBlank()){
return ValidationResults(
successful = false,
errorMessage = R.string.register_user_empty_user_field.toString()
)
}
In presentation:
if(state.username != null){
Text(
text = state.usernameError,
color = Color.Red
)
}
How to properly call String from Resources.
EDIT: I get this error if using:
stringResource(id = R.string.register_user_empty_user_field)
@Composable invocations can only happen from the context of a
