[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Type](https://evolu.dev/docs/api-reference/common/Type) › maxSize

```ts
function maxSize<Max extends number>(
  max: ValidateBrandFactoryCount<Max>,
): BrandFactory<`MaxSize${Max}`, ValueWithSize, MaxSizeError<Max>>;
```

Defined in: [packages/common/src/Type.ts:14728](https://github.com/evoluhq/evolu/blob/bc4578a260dd15d5bbf94b83765ca05984d194cb/packages/common/src/Type.ts#L14728)

Maximum-size [Brand](https://evolu.dev/docs/api-reference/common/Brand/interfaces/Brand) for values whose `size` is at most `max`.

Applies to the same values as [minSize](https://evolu.dev/docs/api-reference/common/Type/functions/minSize). For a Blob or File, such as an
upload, it limits the byte count; `instanceOf(Blob)` also accepts a File. The
size is checked after the parent has validated every element or entry, so it
does not limit the validation work for a large Set or Map.

### Example

```ts
import {
  assertEqual,
  assertErr,
  assertTrue,
  instanceOf,
  maxSize,
} from "@evolu/common";

const Upload = maxSize(1_048_576)(instanceOf(Blob));

assertTrue(Upload.is(new Blob(["Hello"])));

const invalid = Upload.fromUnknown(new Blob([new Uint8Array(1_048_577)]));
assertErr(invalid);
assertEqual(
  Upload.formatError(invalid.error),
  "The size 1048577 exceeds the maximum size of 1048576.",
);
```