<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSessionWebSocketTask/CloseCode-swift.enum/policyViolation",
  "metadataVersion" : "0.1.0",
  "role" : "Case",
  "symbol" : {
    "kind" : "Case",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@E@NSURLSessionWebSocketCloseCode@NSURLSessionWebSocketCloseCodePolicyViolation"
  },
  "title" : "URLSessionWebSocketTask.CloseCode.policyViolation"
}
-->

# URLSessionWebSocketTask.CloseCode.policyViolation

A code that indicates an endpoint terminated the connection because it received a message that violates its policy.

```
case policyViolation
```

## Discussion

This is a generic code for use when a more specific code is unavailable.

---

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)