Skip to content

Commit

Permalink
Fix more documentation errors
Browse files Browse the repository at this point in the history
Signed-off-by: TheRealJan <[email protected]>
  • Loading branch information
jan-tennert committed Aug 23, 2023
1 parent cc04229 commit 3624b73
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
2 changes: 2 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ naming:
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/mingwX64Test/**', '**/macosTest/**', '**/appleTest/**', '**/linuxTest/**']
functionPattern: '[a-z][a-zA-Z0-9]*'
excludeClassPattern: '$^'
ignoreAnnotated:
- Composable
FunctionParameterNaming:
active: true
parameterPattern: '[a-z][A-Za-z0-9]*'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@file:Suppress("MagicNumber")
@file:Suppress("MagicNumber", "UndocumentedPublicFunction", "LongMethod")
package io.github.jan.supabase.compose.auth.ui

import androidx.compose.runtime.Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.compose.ui.unit.dp
import io.github.jan.supabase.annotations.SupabaseExperimental
import io.github.jan.supabase.gotrue.providers.OAuthProvider

val DEFAULT_ICON_SIZE = 24.dp //from Material3
internal val DEFAULT_ICON_SIZE = 24.dp //from Material3

/**
* Displays an icon representing the specified OAuth provider.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,56 @@ package io.github.jan.supabase.compose.auth.ui.password
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember

/**
* Represents a rule that can be applied to a password.
* @param description The description of the rule.
* @param predicate The predicate that determines whether the rule is fulfilled.
*/
class PasswordRule(val description: String, val predicate: (password: String) -> Boolean) {

companion object {

/**
* Creates a [PasswordRule] that checks whether the password is at least [length] characters long.
* @param length The minimum length of the password.
* @param description The description of the rule.
*/
fun minLength(length: Int, description: String = "Password must be at least $length characters long") = PasswordRule(description) {
it.length >= length
}

/**
* Creates a [PasswordRule] that checks whether the password contains at least one lowercase character.
* @param description The description of the rule.
*/
fun containsLowercase(description: String = "Password must contain at least one lowercase character") = PasswordRule(description) {
it.any { char -> char.isLowerCase() }
}

/**
* Creates a [PasswordRule] that checks whether the password contains at least one uppercase character.
*/
fun containsUppercase(description: String = "Password must contain at least one uppercase character") = PasswordRule(description) {
it.any { char -> char.isUpperCase() }
}

/**
* Creates a [PasswordRule] that checks whether the password contains at least one digit.
*/
fun containsDigit(description: String = "Password must contain at least one digit") = PasswordRule(description) {
it.any { char -> char.isDigit() }
}

/**
* Creates a [PasswordRule] that checks whether the password contains at least one special character.
*/
fun containsSpecialCharacter(description: String = "Password must contain at least one special character") = PasswordRule(description) {
it.any { char -> char.isLetterOrDigit().not() }
}

/**
* Creates a [PasswordRule] that checks whether the password is at most [length] characters long.
*/
fun maxLength(length: Int, description: String = "Password must be at most $length characters long") = PasswordRule(description) {
it.length <= length
}
Expand All @@ -35,6 +61,11 @@ class PasswordRule(val description: String, val predicate: (password: String) ->

}

/**
* Represents the result of a [PasswordRule], when applied to a password.
* @param description The description of the rule.
* @param isFulfilled Whether the rule is fulfilled.
*/
data class PasswordRuleResult(val description: String, val isFulfilled: Boolean)

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import io.github.jan.supabase.compose.auth.ui.FormComponent
import io.github.jan.supabase.compose.auth.ui.FormValidator
import io.github.jan.supabase.compose.auth.ui.rememberCallIcon

const val DEFAULT_MASK = "+## ### #########"
const val DEFAULT_MASK_CHAR = '#'
private const val DEFAULT_MASK = "+## ### #########"
private const val DEFAULT_MASK_CHAR = '#'

/**
* A custom email input field with validation and pre-defined styling.
Expand Down

0 comments on commit 3624b73

Please sign in to comment.