[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) › PortFromString

```ts
const PortFromString: transform(
  "PortFromString",
  IntFromString,
  Port,
  { from: ok, to: identity },
);
```

Defined in: [packages/common/src/Type.ts:8384](https://github.com/evoluhq/evolu/blob/ecbac001e0c18bbc45b44715f49ecc3a768c5ec9/packages/common/src/Type.ts#L8384)

Parses a decimal integer string and validates it as a [Port](https://evolu.dev/docs/api-reference/common/Type/variables/Port).

Uses [IntFromString](https://evolu.dev/docs/api-reference/common/Type/variables/IntFromString) for decimal parsing, including its rejection of
whitespace, plus signs, fractions, and exponent notation.

### Example

```ts
import {
  assertEqual,
  assertErr,
  assertOk,
  PortFromString,
} from "@evolu/common";

assertOk(PortFromString.fromUnknown("0"), 0);
assertOk(PortFromString.fromUnknown("4000"), 4000);
assertErr(PortFromString.fromUnknown("65536"));
assertErr(PortFromString.fromUnknown("http"));
assertEqual(PortFromString.to(PortFromString.orThrow("04000")), "4000");
```