<!--
{
  "availability" : [
    "Xcode: 27.0.0 -",
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Evaluations",
  "identifier" : "/documentation/Evaluations/SampleGenerator/validator",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Evaluations"
    ],
    "preciseIdentifier" : "s:11Evaluations15SampleGeneratorC9validatorSbxYaYbKYCcSgvp"
  },
  "title" : "validator"
}
-->

# validator

An optional closure that decides whether a generated sample is valid.

```
var validator: (nonisolated(nonsending) @Sendable (SampleType) async throws -> Bool)? { get }
```

## Discussion

When provided, the generator collects rejected samples in [`invalidSamples`](/documentation/Evaluations/SampleGenerator/invalidSamples).

---

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)