Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions fern/products/api-def/ferndef-pages/types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ interface Person {

### Validating types

You can add validation constraints to your types (both aliases and references) to ensure data integrity. Validation constracts are automatically enforced in generated SDKs.
You can add validation constraints to your types (both aliases and references) to ensure data integrity. These validation constraints exist in your API definition and are enforced by the server, but the generated client SDKs don't include validation logic.

<CodeBlock title="Fern Definition">
```yaml {8-11, 15-17}
Expand All @@ -305,30 +305,6 @@ types:
max: 150
```
</CodeBlock>
<CodeBlock title="Generated TypeScript SDK from Fern Definition">

```typescript
interface Person {
/** The person's full name */
name: string;
/** Age in years */
age: number;
}

// Validation is automatically enforced when creating Person objects
const client = new YourApiClient();
try {
const person = await client.createPerson({
name: "A", // Fails minLength validation
age: -5, // Fails min validation
});
} catch (error) {
if (error instanceof ValidationError) {
console.log(`Validation failed: ${error.message}`);
}
}
```
</CodeBlock>

<AccordionGroup>
<Accordion title="String validation reference">
Expand Down