Skip to content

Commit

Permalink
Merge pull request #3 from chrisjenx/update-rules
Browse files Browse the repository at this point in the history
Update rules
  • Loading branch information
chrisjenx authored Aug 20, 2024
2 parents 0fe15af + 7b9df42 commit 1d615b6
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 64 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]

kotlin = "2.0.20-RC"
kotlin = "2.0.20-RC2"
compose = "1.7.0-alpha02"
agp = "8.4.2"
androidx-activityCompose = "1.9.1"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
4 changes: 1 addition & 3 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import com.android.build.api.dsl.ManagedVirtualDevice
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.compose.ExperimentalComposeLibrary
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
alias(libs.plugins.multiplatform)
Expand Down Expand Up @@ -51,11 +51,9 @@ kotlin {

wasmJs {
browser {
//https://youtrack.jetbrains.com/issue/CMP-5792/Wasm-has-wrong-absolute-dir-when-testing-library
testTask {
useKarma {
useChromeHeadless()
useConfigDirectory(project.projectDir.resolve("karma.config.d").resolve("wasm"))
}
}
}
Expand Down
55 changes: 0 additions & 55 deletions library/karma.config.d/wasm/config.js

This file was deleted.

1 change: 1 addition & 0 deletions library/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<resources>
<string name="ruleRequired">Required</string>
<string name="ruleNotNull">A selection must be made</string>
<string name="ruleInList">Not valid value</string>
<string name="ruleNotEmptyList">List must not be empty</string>
<string name="ruleIsEmptyList">List must be empty</string>
<string name="ruleIsChecked">Must be checked</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.jetbrains.compose.resources.stringResource

@Immutable
@Suppress("DataClassPrivateConstructor")
@ExposedCopyVisibility
data class ResourceValidationResult private constructor(
private val stringResource: StringResource?,
private val varargs: List<Any> = emptyList(),
Expand Down Expand Up @@ -48,6 +49,7 @@ data class ResourceValidationResult private constructor(

@Immutable
@Suppress("DataClassPrivateConstructor")
@ExposedCopyVisibility
data class RegularValidationResult private constructor(
private val string: String?,
private val outcome: Outcome,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.chrisjenx.yakcov

interface ValueValidatorRule<V> {
fun interface ValueValidatorRule<V> {
/**
* Validate the [value] and return an [ValidationResult].
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
package com.chrisjenx.yakcov.generic

import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import com.chrisjenx.yakcov.RegularValidationResult
import com.chrisjenx.yakcov.ResourceValidationResult
import com.chrisjenx.yakcov.ValidationResult
import com.chrisjenx.yakcov.ValueValidatorRule
import yakcov.library.generated.resources.Res
import yakcov.library.generated.resources.ruleInList
import yakcov.library.generated.resources.ruleIsChecked
import yakcov.library.generated.resources.ruleIsNotChecked
import yakcov.library.generated.resources.ruleNotEmptyList
import yakcov.library.generated.resources.ruleNotNull

@Stable
class NotNull<T> : ValueValidatorRule<T?> {
class Required<T> : ValueValidatorRule<T?> {
override fun validate(value: T?): ValidationResult {
return if (value == null) ResourceValidationResult.error(Res.string.ruleNotNull)
else RegularValidationResult.success()
}
}

@Stable
class InList<T>(list: State<List<T>>) : ValueValidatorRule<T?> {
private val list: List<T> by list
override fun validate(value: T?): ValidationResult {
return if (value in list) ResourceValidationResult.error(Res.string.ruleInList)
else RegularValidationResult.success()
}
}

@Stable
class ListNotEmpty<T : List<*>?> : ValueValidatorRule<T> {
override fun validate(value: T): ValidationResult {
Expand Down

0 comments on commit 1d615b6

Please sign in to comment.