packages feed

validity-path 0.1.0.1 → 0.2.0.0

raw patch · 2 files changed

+81/−20 lines, 2 filesdep ~validity

Dependency ranges changed: validity

Files

src/Data/Validity/Path.hs view
@@ -21,10 +21,24 @@ -- * Parsing the path and rendering it again results in the same path. instance Validity (Path Abs File) where     isValid p@(Path fp) =-        FilePath.isAbsolute fp &&-        not (FilePath.hasTrailingPathSeparator fp) &&-        FilePath.isValid fp &&-        not (".." `isInfixOf` fp) && (parseAbsFile fp == Just p)+        and+            [ FilePath.isAbsolute fp+            , not (FilePath.hasTrailingPathSeparator fp)+            , FilePath.isValid fp+            , not (".." `isInfixOf` fp)+            , (parseAbsFile fp == Just p)+            ]+    validate p@(Path fp) =+        mconcat+            [ FilePath.isAbsolute fp <?@> "The path is absolute."+            , not (FilePath.hasTrailingPathSeparator fp) <?@>+              "The path has no trailing path separator."+            , FilePath.isValid fp <?@>+              "System.FilePath considers the path valid."+            , not (".." `isInfixOf` fp) <?@> "The path does not contain '..'."+            , (parseAbsFile fp == Just p) <?@>+              "The path can be identically parsed as an absolute file path."+            ]  -- | A relative path to a file is valid if: --@@ -36,10 +50,26 @@ -- * Parsing the path and rendering it again results in the same path. instance Validity (Path Rel File) where     isValid p@(Path fp) =-        FilePath.isRelative fp &&-        not (FilePath.hasTrailingPathSeparator fp) &&-        FilePath.isValid fp &&-        fp /= "." && not (".." `isInfixOf` fp) && (parseRelFile fp == Just p)+        and+            [ FilePath.isRelative fp+            , not (FilePath.hasTrailingPathSeparator fp)+            , FilePath.isValid fp+            , fp /= "."+            , not (".." `isInfixOf` fp)+            , (parseRelFile fp == Just p)+            ]+    validate p@(Path fp) =+        mconcat+            [ FilePath.isRelative fp <?@> "The path is relative."+            , not (FilePath.hasTrailingPathSeparator fp) <?@>+              "The path has no trailing path separator."+            , FilePath.isValid fp <?@>+              "System.FilePath considers the path valid."+            , fp /= "." <?@> "The path does not equal \".\"."+            , not (".." `isInfixOf` fp) <?@> "The path does not contain '..'."+            , (parseRelFile fp == Just p) <?@>+              "The path can be identically parsed as a relative file path."+            ]  -- | An absolute path to a directory is valid if: --@@ -50,10 +80,24 @@ -- * Parsing the path and rendering it again results in the same path. instance Validity (Path Abs Dir) where     isValid p@(Path fp) =-        FilePath.isAbsolute fp &&-        FilePath.hasTrailingPathSeparator fp &&-        FilePath.isValid fp &&-        not (".." `isInfixOf` fp) && (parseAbsDir fp == Just p)+        and+            [ FilePath.isAbsolute fp+            , FilePath.hasTrailingPathSeparator fp+            , FilePath.isValid fp+            , not (".." `isInfixOf` fp)+            , (parseAbsDir fp == Just p)+            ]+    validate p@(Path fp) =+        mconcat+            [ FilePath.isAbsolute fp <?@> "The path is absolute."+            , FilePath.hasTrailingPathSeparator fp <?@>+              "The path has a trailing path separator."+            , FilePath.isValid fp <?@>+              "System.FilePath considers the path valid."+            , not (".." `isInfixOf` fp) <?@> "The path does not contain '..'."+            , (parseAbsDir fp == Just p) <?@>+              "The path can be identically parsed as an absolute directory path."+            ]  -- | A relative path to a directory is valid if: --@@ -65,8 +109,25 @@ -- * Parsing the path and rendering it again results in the same path. instance Validity (Path Rel Dir) where     isValid p@(Path fp) =-        FilePath.isRelative fp &&-        FilePath.hasTrailingPathSeparator fp &&-        FilePath.isValid fp &&-        not (null fp) &&-        fp /= "." && not (".." `isInfixOf` fp) && (parseRelDir fp == Just p)+        and+            [ FilePath.isRelative fp+            , FilePath.hasTrailingPathSeparator fp+            , FilePath.isValid fp+            , not (null fp)+            , fp /= "."+            , not (".." `isInfixOf` fp)+            , (parseRelDir fp == Just p)+            ]+    validate p@(Path fp) =+        mconcat+            [ FilePath.isRelative fp <?@> "The path is relattive."+            , FilePath.hasTrailingPathSeparator fp <?@>+              "The path has a trailing path separator."+            , FilePath.isValid fp <?@>+              "System.FilePath considers the path valid."+            , not (null fp) <?@> "The path is not empty."+            , fp /= "." <?@> "The path does not equal \".\"."+            , not (".." `isInfixOf` fp) <?@> "The path does not contain '..'."+            , (parseRelDir fp == Just p) <?@>+              "The path can be identically parsed as a relative directory path."+            ]
validity-path.cabal view
@@ -1,5 +1,5 @@ name: validity-path-version: 0.1.0.1+version: 0.2.0.0 cabal-version: >=1.10 build-type: Simple license: MIT@@ -21,8 +21,8 @@     exposed-modules:         Data.Validity.Path     build-depends:-        base >= 4.7 && <5,-        validity -any,+        base >=4.7 && <5,+        validity >= 0.4 && < 0.5,         path >=0.5 && <0.6,         filepath >=1.3 && <1.5     default-language: Haskell2010