All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.schemas.ByteSchema.kt Maven / Gradle / Ivy

There is a newer version: 4.10.0-legacy-ie11
Show newest version
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.Schema
import pt.lightweightform.lfkotlin.Validation

internal expect fun byteSchemaImpl(
    isNullable: Boolean,
    initialValue: Byte?,
    computedInitialValue: InitialValue?,
    computedValue: ComputedValue?,
    mismatchedComputedCode: String?,
    isClientOnly: Boolean?,
    isRequired: Boolean?,
    computedIsRequired: IsRequired?,
    isRequiredCode: String?,
    allowedValues: List?,
    computedAllowedValues: AllowedValues?,
    disallowedValueCode: String?,
    min: Byte?,
    computedMin: Bound?,
    minCode: String?,
    max: Byte?,
    computedMax: Bound?,
    maxCode: String?,
    validations: List>?,
    initialState: Map?,
    extra: Map?
): Schema

/**
 * Creates a byte schema. Maps to a schema of type "number" with `isInteger` set to `true` and
 * appropriate min/max bounds in LF.
 */
@Suppress("UNCHECKED_CAST")
public fun byteSchema(
    initialValue: Byte? = null,
    computedInitialValue: InitialValue? = null,
    computedValue: ComputedValue? = null,
    mismatchedComputedCode: String? = null,
    isClientOnly: Boolean? = null,
    allowedValues: List? = null,
    computedAllowedValues: AllowedValues? = null,
    disallowedValueCode: String? = null,
    min: Byte? = null,
    computedMin: Bound? = null,
    minCode: String? = null,
    max: Byte? = null,
    computedMax: Bound? = null,
    maxCode: String? = null,
    validations: List>? = null,
    initialState: Map? = null,
    extra: Map? = null
): Schema =
    byteSchemaImpl(
        false,
        initialValue,
        computedInitialValue,
        computedValue as ComputedValue?,
        mismatchedComputedCode,
        isClientOnly,
        null,
        null,
        null,
        allowedValues,
        computedAllowedValues,
        disallowedValueCode,
        min,
        computedMin,
        minCode,
        max,
        computedMax,
        maxCode,
        validations,
        initialState,
        extra
    ) as
        Schema

/**
 * Creates a nullable byte schema. Maps to a schema of type "number" with `isNullable` set to
 * `true`, `isInteger` set to `true` and appropriate min/max bounds in LF.
 */
@Suppress("UNCHECKED_CAST")
public fun nullableByteSchema(
    initialValue: Byte? = null,
    computedInitialValue: InitialValue? = null,
    computedValue: ComputedValue? = null,
    mismatchedComputedCode: String? = null,
    isClientOnly: Boolean? = null,
    isRequired: Boolean? = null,
    computedIsRequired: IsRequired? = null,
    isRequiredCode: String? = null,
    allowedValues: List? = null,
    computedAllowedValues: AllowedValues? = null,
    disallowedValueCode: String? = null,
    min: Byte? = null,
    computedMin: Bound? = null,
    minCode: String? = null,
    max: Byte? = null,
    computedMax: Bound? = null,
    maxCode: String? = null,
    validations: List>? = null,
    initialState: Map? = null,
    extra: Map? = null
): Schema =
    byteSchemaImpl(
        true,
        initialValue,
        computedInitialValue,
        computedValue,
        mismatchedComputedCode,
        isClientOnly,
        isRequired,
        computedIsRequired,
        isRequiredCode,
        allowedValues,
        computedAllowedValues,
        disallowedValueCode,
        min,
        computedMin,
        minCode,
        max,
        computedMax,
        maxCode,
        validations,
        initialState,
        extra
    )




© 2015 - 2025 Weber Informatics LLC | Privacy Policy