Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Doc.InputType.Decimal and Doc.InputType.DecimalUnchecked #260

Merged

Conversation

diegopego
Copy link
Contributor

No description provided.

@diegopego
Copy link
Contributor Author

diegopego commented Jan 3, 2023

I have an issue with this code regarding this formula:

System.Math.Round(1.1m, 1) = 1.1m // returns true

let RoundCheckedInput places (f:CheckedInput<decimal>) =
    match f with
    | Valid(value, inputText) -> Math.Round(value, places)

let checkedInput = CheckedInput.Make(1.1m)

Doc.Concat [
    h1 [] [text $"{RoundCheckedInput 2m checkedInput} {(RoundCheckedInput 2m checkedInput) = 1.1m}"] // returns 1.1 true

when debugging on the browser, value evaluates to value: 1.26

Here is the issue:

If I submit the following form, filling the field with 1.1, the validation fails, and it should pass.

let ValidateCheckedDecimalPlaces places (f:CheckedInput<decimal>) =
    match f with
    | Valid(value, inputText) -> Math.Round(value, places) = value // returns false

Form.Return (fun sku description price quantity -> sku, description, price, quantity)
<*> (Form.Yield (CheckedInput.Make 0.0m)
    |> Validation.Is (fun x -> ValidateCheckedDecimalPlaces 2m x) "Price must have up to two decimal places" // 
    )

when debugging on the browser, value evaluates to:

value: a
    constructor: f a(e)
    d: (2) [1,1000000]
    e: 0
    s: 1

@Jand42
Copy link
Member

Jand42 commented Jan 9, 2023

@diegopego Hello, I'm sorry, can you clean up all the project file changes with the explicit package updates? You can run ./build WS-Update to update deps only or ./build CI-Release to update+build+package everything as CI does.

@diegopego
Copy link
Contributor Author

@diegopego Hello, I'm sorry, can you clean up all the project file changes with the explicit package updates? You can run ./build WS-Update to update deps only or ./build CI-Release to update+build+package everything as CI does.

I did it and pushed a new commit.

@Jooseppi12 Jooseppi12 merged commit 45bec61 into dotnet-websharper:master Jan 13, 2023
@diegopego diegopego deleted the diegopego-decimal-input branch January 15, 2023 23:13
@diegopego diegopego restored the diegopego-decimal-input branch January 15, 2023 23:13
@diegopego diegopego deleted the diegopego-decimal-input branch January 16, 2023 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants