# Objects

`{"type": "object"}` generates a random dict. Without any property schemas, keys are generated from the [`default_property_schema`](../quickstart.md#context-options) (default: a username-style string) and values are random JSON-compatible types.

---

## Declared properties

### `properties` / `required`

```json
{
  "type": "object",
  "properties": {
    "name":  {"type": "string"},
    "age":   {"type": "integer", "minimum": 0, "maximum": 120},
    "email": {"type": "string", "format": "email"}
  },
  "required": ["name", "age"]
}
```

```python
{"name": "Environment step remember building often.", "age": 50}
```

**Strategy:** all `required` properties are always generated. Non-required properties are included randomly (50 % chance each by default). Each property value is generated from its own sub-schema.

---

## Additional properties

### `additionalProperties`

Accepts a boolean or a sub-schema.

**Boolean `false` — no extra properties:**

```json
{
  "type": "object",
  "properties": {"x": {"type": "number"}, "y": {"type": "number"}},
  "additionalProperties": false,
  "required": ["x", "y"]
}
```

```python
{"x": 241018478919341.0, "y": 271085779180678.5}
```

**Schema — extra properties follow a type:**

```json
{
  "type": "object",
  "properties": {"id": {"type": "integer"}},
  "additionalProperties": {"type": "boolean"},
  "minProperties": 3,
  "maxProperties": 4
}
```

```python
{"andersoncourtney": True, "rcarey": False, "gcook": True, "rebecca05": False}
```

**Strategy:** declared `properties` are generated first. If more properties are needed to reach `minProperties`, additional ones are generated using the `additionalProperties` schema (or any type if it is `true`). Property names for additional properties come from the `default_property_schema` context option. When `unevaluatedProperties` is also present, keys produced through an `additionalProperties` schema are treated as already evaluated.

**Limitations:** `additionalProperties: false` with `minProperties` greater than the number of declared properties raises `UnsatisfiableConstraintsError`. If `additionalProperties` is just `true`, those extra keys are still considered unevaluated for `unevaluatedProperties` processing because there is no schema application to mark them as evaluated.

---

## Pattern properties

### `patternProperties`

```json
{
  "type": "object",
  "patternProperties": {"^x-": {"type": "string"}},
  "minProperties": 2,
  "maxProperties": 3
}
```

```python
{"x-óZå": "Major weight himself space activity...", "melissabarber": "National impact respond..."}
```

**Strategy:** for each pattern key, generates one property whose name matches the pattern and whose value conforms to the schema. If `propertyNames` is present, the generated key must satisfy both the pattern and the `propertyNames` sub-schema before it is accepted. Additional properties (not covered by any pattern) may also be generated to satisfy `minProperties`.

**Limitations:** generated keys are not guaranteed to be human-readable; the pattern engine may produce Unicode characters or unusual strings when the regex allows them. If `patternProperties` and `propertyNames` together leave no valid key space, generation raises `UnsatisfiableConstraintsError`.

---

## Property name schema

### `propertyNames`

```json
{
  "type": "object",
  "propertyNames": {"pattern": "^[a-z]{3,8}$"},
  "additionalProperties": {"type": "integer"},
  "minProperties": 2,
  "maxProperties": 3
}
```

```python
{"bqe": 1731, "vaa": 9228}
```

**Strategy:** property names are generated by applying `propertyNames` as a string sub-schema (using the `pattern` strategy). The same constraint also applies when keys are generated for `patternProperties` and schema-valued `additionalProperties`.

**Limitations:** `propertyNames` applies to all property names including those declared in `properties`. If a declared property name does not conform to `propertyNames`, or if `propertyNames` conflicts with `patternProperties`, the schema is inconsistent and generation may raise `UnsatisfiableConstraintsError`.

---

## Unevaluated properties

### `unevaluatedProperties`

```json
{
  "type": "object",
  "properties": {"name": {"type": "string"}},
  "required": ["name"],
  "additionalProperties": {"type": "integer"},
  "unevaluatedProperties": false,
  "minProperties": 2,
  "maxProperties": 2
}
```

```python
{"name": "Alice", "guest_count": 3}
```

**Strategy:** after generating declared, patterned, and additional properties, the generator computes which keys have been evaluated by the active object keywords. Keys produced by schema-valued `additionalProperties` are preserved as evaluated keys; remaining unevaluated keys are either removed (`false`) or regenerated from the `unevaluatedProperties` schema.

**Limitations:** only keys touched by a schema-valued `additionalProperties` are treated as evaluated through that keyword. When `additionalProperties` is `true`, extra keys remain unevaluated and may therefore be removed or rewritten by `unevaluatedProperties`.

---

## Property count

### `minProperties` / `maxProperties`

```json
{
  "type": "object",
  "additionalProperties": {"type": "boolean"},
  "minProperties": 2,
  "maxProperties": 3
}
```

```python
{"mburton": True, "kimberlycline": True}
```

**Strategy:** the total property count is chosen uniformly in `[minProperties, maxProperties]`.

---

## Dependent keywords

### `dependentRequired`

```json
{
  "type": "object",
  "properties": {
    "credit_card":     {"type": "string"},
    "billing_address": {"type": "string"},
    "name":            {"type": "string"}
  },
  "required": ["name"],
  "dependentRequired": {"credit_card": ["billing_address"]}
}
```

```python
{
    "name": "Unit study thus executive cost do.",
    "billing_address": "Purpose top nice case agree.",
    "credit_card": "Property administration news term meeting who style.",
}
```

**Strategy:** if a trigger property is present in the generated object, all properties it depends on are added automatically. The trigger property itself may or may not appear (it is not `required` unless listed there).

---

### `dependentSchemas`

```json
{
  "type": "object",
  "properties": {"plan": {"type": "string", "enum": ["free", "pro"]}},
  "required": ["plan"],
  "dependentSchemas": {
    "plan": {"properties": {"seats": {"type": "integer", "minimum": 1}}}
  }
}
```

```python
{"plan": "free", "whitekatrina": None, "adaniels": 4796}
```

**Strategy:** if a trigger property ends up in the object, the dependent schema is merged into the overall object schema and generation continues with the merged constraints. This means additional properties or constraints from the dependent schema are applied.

**Limitations:** `dependentSchemas` merging uses the same constraint-merge logic as `allOf`. Conflicting types between the base schema and a dependent schema will raise `UnsatisfiableConstraintsError`.
