---
title: PredicateCodableConfiguration
framework: foundation
role: symbol
role_heading: Structure
path: foundation/predicatecodableconfiguration
---

# PredicateCodableConfiguration

A specification of the expected types and key paths found in an archived predicate.

## Declaration

```swift
struct PredicateCodableConfiguration
```

## Overview

Overview Use this configuration when encoding and decoding a predicate to restrict what that predicate can contain.  If a predicate contains data types or keypaths that aren’t allowed by the configuration, the encoding or decoding process throws an error. var configuration = PredicateCodableConfiguration.standardConfiguration configuration.allowType(Message.self, identifier: "MyApp.Message") configuration.allowType(Person.self, identifier: "MyApp.Person") configuration.allowKeyPath(\Message.sender, identifier: "MyApp.Message.sender") configuration.allowKeyPath(\Person.firstName, identifier: "MyApp.Person.firstName") configuration.allowKeyPath(\Person.lastName, identifier: "MyApp.Person.lastName")

struct MyRequest: Codable {     let predicate: Predicate<Message>          func encode(to encoder: Encoder) throws {         var container = encoder.container(keyedBy: CodingKeys.self)         try container.encode(predicate, forKey: .predicate, configuration: configuration)     }          init(from decoder: Decoder) throws {         let container = try decoder.container(keyedBy: CodingKeys.self)         predicate = try container.decode(Predicate<Message>.self, forKey: .predicate, configuration: configuration)     } }

## Topics

### Creating a configuration

- [init()](foundation/predicatecodableconfiguration/init().md)
- [standardConfiguration](foundation/predicatecodableconfiguration/standardconfiguration.md)

### Allowing types and key paths

- [allow(_:)](foundation/predicatecodableconfiguration/allow(_:).md)
- [allowKeyPathsForPropertiesProvided(by:recursive:)](foundation/predicatecodableconfiguration/allowkeypathsforpropertiesprovided(by:recursive:).md)
- [allowPartialType(_:identifier:)](foundation/predicatecodableconfiguration/allowpartialtype(_:identifier:).md)
- [allowType(_:identifier:)](foundation/predicatecodableconfiguration/allowtype(_:identifier:).md)

### Disallowing types and key paths

- [disallowKeyPathsForPropertiesProvided(by:recursive:)](foundation/predicatecodableconfiguration/disallowkeypathsforpropertiesprovided(by:recursive:).md)
- [disallowPartialType(_:)](foundation/predicatecodableconfiguration/disallowpartialtype(_:).md)
- [disallowType(_:)](foundation/predicatecodableconfiguration/disallowtype(_:).md)

### Instance Methods

- [allowKeyPath(_:identifier:)](foundation/predicatecodableconfiguration/allowkeypath(_:identifier:).md)
- [disallowKeyPath(_:)](foundation/predicatecodableconfiguration/disallowkeypath(_:).md)

## Relationships

### Conforms To

- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Filltering

- [Predicate](foundation/predicate.md)
- [PredicateError](foundation/predicateerror.md)
- [PredicateCodableKeyPathProviding](foundation/predicatecodablekeypathproviding.md)
- [PredicateExpression](foundation/predicateexpression.md)
- [StandardPredicateExpression](foundation/standardpredicateexpression.md)
- [PredicateExpressions](foundation/predicateexpressions.md)
- [PredicateBindings](foundation/predicatebindings.md)
- [NSPredicate](foundation/nspredicate.md)
- [NSExpression](foundation/nsexpression.md)
- [NSComparisonPredicate](foundation/nscomparisonpredicate.md)
- [NSCompoundPredicate](foundation/nscompoundpredicate.md)
