jsMain.schemas.LongSchema.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lf-kotlin-js Show documentation
Show all versions of lf-kotlin-js Show documentation
Kotlin integration for Lightweightform
package pt.lightweightform.lfkotlin.schemas
import pt.lightweightform.lfkotlin.AllowedValues
import pt.lightweightform.lfkotlin.Bound
import pt.lightweightform.lfkotlin.ComputedValue
import pt.lightweightform.lfkotlin.InitialValue
import pt.lightweightform.lfkotlin.IsRequired
import pt.lightweightform.lfkotlin.LF_LONG_MAX_VALUE
import pt.lightweightform.lfkotlin.LF_LONG_MIN_VALUE
import pt.lightweightform.lfkotlin.LfLong
import pt.lightweightform.lfkotlin.Schema
import pt.lightweightform.lfkotlin.Validation
import pt.lightweightform.lfkotlin.internal.addCommonPropsToSchema
import pt.lightweightform.lfkotlin.internal.toStorageBound
@Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE")
internal actual fun longSchemaImpl(
isNullable: Boolean,
initialValue: LfLong?,
computedInitialValue: InitialValue?,
computedValue: ComputedValue?,
mismatchedComputedCode: String?,
isClientOnly: Boolean?,
isRequired: Boolean?,
computedIsRequired: IsRequired?,
isRequiredCode: String?,
allowedValues: List?,
computedAllowedValues: AllowedValues?,
disallowedValueCode: String?,
min: LfLong?,
computedMin: Bound?,
minCode: String?,
max: LfLong?,
computedMax: Bound?,
maxCode: String?,
validations: List>?,
initialState: Map?,
extra: Map?
): Schema {
val schema = js("{}") as Schema
schema.asDynamic().isInteger = true
addCommonPropsToSchema(
schema,
"number",
isNullable,
initialValue,
computedInitialValue,
computedValue,
isClientOnly,
isRequired,
computedIsRequired,
isRequiredCode,
allowedValues,
computedAllowedValues,
disallowedValueCode,
validations,
initialState,
extra
)
schema.asDynamic().min =
when {
min != null -> min
computedMin != null -> toStorageBound(computedMin)
else -> LF_LONG_MIN_VALUE
}
schema.asDynamic().minCode = minCode ?: undefined
schema.asDynamic().max =
when {
max != null -> max
computedMax != null -> toStorageBound(computedMax)
else -> LF_LONG_MAX_VALUE
}
schema.asDynamic().maxCode = maxCode ?: undefined
return schema
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy