<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/String/init(validating:)-6r2j9",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SS6SystemE10validatingSSSgAA8FilePathV4RootV_tcfc"
  },
  "title" : "init(validating:)"
}
-->

# init(validating:)

On Unix, creates the string `"/"`

```
init?(validating root: FilePath.Root)
```

## Parameters

`root`

The path root to be interpreted as
`CInterop.PlatformUnicodeEncoding`.

## Discussion

On Windows, creates a string from a path root, validating its contents as
UTF-16 on Windows.

On Windows, if the contents of the path root isn’t a well-formed Unicode
string, this initializer returns `nil`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)