Death Socket consists of three projects. They are a .Net Standard 2.0 library, a console program and a Test Centre. The purpose of this repository is to provide a way for people to add grids to images.
https://www.craigoates.net/Software/project/13
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1022 B
31 lines
1022 B
5 years ago
|
module internal ValidationServices
|
||
|
|
||
|
open System.IO
|
||
|
|
||
|
let validateFilePath path =
|
||
|
match File.Exists path with
|
||
|
| true -> ()
|
||
|
| false -> raise (new FileNotFoundException ("No file found at " + path))
|
||
|
|
||
|
let validateSaveFileType file =
|
||
|
match Path.GetExtension file with
|
||
|
| ".jpg" -> ()
|
||
|
| ".JPG" -> ()
|
||
|
| ".png" -> ()
|
||
|
| ".PNG" -> ()
|
||
|
| _ -> invalidArg "savePath" "The file type must be a .jpg or .png file."
|
||
|
|
||
|
let validateIO iPath oPath =
|
||
|
validateFilePath iPath
|
||
|
validateSaveFileType oPath
|
||
|
|
||
|
let validateDimensions dimensions =
|
||
|
match dimensions with
|
||
|
| (0, _) -> invalidArg "Width" "Width must be greater than 0."
|
||
|
| (_, 0) -> invalidArg "Height" "Height must be greater than 0."
|
||
|
| (_, _) -> ()
|
||
|
|
||
|
let validateLineThickness thickness =
|
||
|
match thickness with
|
||
|
| thickness when thickness <= 0.0 -> invalidArg "LineThickness" "LineThickness must be greater than 0."
|
||
|
| _ -> ()
|