# 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.

**Limitations:** `additionalProperties: false` with `minProperties` greater than the number of declared properties raises `UnsatisfiableConstraintsError`.

---

## 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 starts with a string matching the pattern, and whose value conforms to the schema. Additional properties (not covered by any pattern) may also be generated to satisfy `minProperties`.

**Limitations:** generated keys satisfy the pattern but are not guaranteed to be human-readable; the pattern engine may produce Unicode characters or unusual strings when the regex allows them.

---

## 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). Values follow `additionalProperties`.

**Limitations:** `propertyNames` applies to all property names including those declared in `properties`. If a declared property name does not conform to `propertyNames`, the schema is inconsistent and generation may produce invalid results.

---

## 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`.
