Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -953,22 +953,21 @@ module Example.Types
qed
}

let! _ = validation {
withValue (name, username)
disputeWithFact NameMatchesUsername (fun (n, u) ->
match n with
| Some nameVal -> Name.unwrap nameVal <> Username.unwrap u
| None -> true
)
and! _ = validation {
withValue vm
disputeWithFact NameMatchesUsername (fun a -> a.Name <> a.Username)
qed
}

return { NewUser.name = name; username = username; password = password; emailAddress = emailAddress; }
} |> fromVCtx
```

We need to include this in the `let!` chain but we can ignore the result.
We need to include this in the `and!` chain but we can ignore the result.
Our complex type is validated.

> **Note:** The example above compares the raw view model values before any validation occurs. If you need to perform cross-field checks on values that have already been individually validated (e.g., comparing two validated fields), see the [Cross-Field Validation](#cross-field-validation) section.

However, as far as complex types go, ours is fairly simple
Let's try validating a type nested inside another type.

Expand Down