# assertPieceValid

> **assertPieceValid**(`piece`): `void`

Defined in: [packages/synapse-core/src/sp/add-pieces-fits.ts:210](https://github.com/FilOzone/synapse-sdk/blob/56f1ef3fb5ccfea19fb80cb59e997e381f37d85a/packages/synapse-core/src/sp/add-pieces-fits.ts#L210)

Throw if a piece can never be added: its PieceCID size is outside Curio's upload bounds or its
metadata exceeds the contract limits. Use it to reject bad pieces before any network work.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `piece` | [`LimiterPiece`](/reference/filoz/synapse-core/sp/type-aliases/limiterpiece/) | The piece to check. |

## Returns

`void`

## Throws

InvalidUploadSizeError when the PieceCID size is below [SIZE\_CONSTANTS.MIN\_UPLOAD\_SIZE](/reference/filoz/synapse-core/utils/variables/size_constants/#min_upload_size) or above [SIZE\_CONSTANTS.MAX\_UPLOAD\_SIZE](/reference/filoz/synapse-core/utils/variables/size_constants/#max_upload_size)

## Throws

Error when the piece metadata exceeds the contract limits