Skip to content

Commit 661d23c

Browse files
committed
Modified required text validator
1 parent 508e748 commit 661d23c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

library/src/main/java/co/kyash/vtl/validators/RequiredValidator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class RequiredValidator(
3636
* @return result
3737
*/
3838
override fun validate(text: String?): Boolean {
39-
return !TextUtils.isEmpty(text)
39+
return !TextUtils.isEmpty(text?.trim())
4040
}
4141

4242
/**

library/src/test/java/co/kyash/vtl/validators/RequiredValidatorTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class RequiredValidatorTest(
2727
return listOf(
2828
arrayOf(null, false, ERROR_MESSAGE),
2929
arrayOf("", false, ERROR_MESSAGE),
30+
arrayOf(" ", false, ERROR_MESSAGE),
31+
arrayOf(" ", false, ERROR_MESSAGE),
3032
arrayOf("konifar", true, null)
3133
)
3234
}

0 commit comments

Comments
 (0)