lfr / FSharp.Domain.Validation

Designing with types requires a lot of code - this library fixes that
MIT License
143 stars 7 forks source link

System.NullReferenceException when validating null string #4

Closed pkuo closed 3 years ago

pkuo commented 3 years ago

Getting a exception when validating null strings in version 0.9.71+. Works in version 0.9.7

Exception: System.NullReferenceException: Object reference not set to an instance of an object. at FSharp.ValidationBlocks.Block`2.validate[block](a inp)

open FSharp.ValidationBlocks

type TextBlock =
    inherit IBlock<string, string>

type FreeText =
    private
    | FreeText of string
    interface TextBlock with
        member _.Validate =
            fun s -> [ if s |> System.String.IsNullOrWhiteSpace then "Is Missing Or Blank" ]

let s: string = null

let text = s |> Block.validate<FreeText>
lfr commented 3 years ago

https://www.nuget.org/packages/FSharp.ValidationBlocks/0.9.75-beta

Thanks, can you test this one and let me know how it goes please

pkuo commented 3 years ago

It fixes the null string validation. Thanks.

lfr commented 3 years ago

Great, let me know if you see something else with this build, if not I'll make it a release.

pkuo commented 3 years ago

Nothing else with this build.

lfr commented 3 years ago

https://www.nuget.org/packages/FSharp.ValidationBlocks/0.9.75