This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"valueParameterInfo":[],"slotParameterDescriptions":[],"roleDescriptions":[],"contractType":"O","contractShortDescription":"","contractName":"","contractLongDescription":"","choiceInfo":[]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module StringConstraints | |
open System | |
let stringPattern str pattern = | |
if String.IsNullOrEmpty(str) then | |
let msg = sprintf "%s: Must not be null or empty" str | |
Error msg | |
elif System.Text.RegularExpressions.Regex.IsMatch(str, pattern) then | |
Ok (str) | |
else | |
let msg = sprintf "'%s' must match the pattern '%s'" str pattern |