From 026f556ea1a2fb850a68cc5374ab5d2409d8d9c2 Mon Sep 17 00:00:00 2001
From: "promptless[bot]" <179508745+promptless[bot]@users.noreply.github.com>
Date: Thu, 7 Aug 2025 17:12:43 +0000
Subject: [PATCH 1/3] Documentation updates from Promptless
---
fern/products/fern-def/pages/types.mdx | 292 ++++++++++++++++++++++++-
1 file changed, 291 insertions(+), 1 deletion(-)
diff --git a/fern/products/fern-def/pages/types.mdx b/fern/products/fern-def/pages/types.mdx
index 3769526f6..8c1289bb1 100644
--- a/fern/products/fern-def/pages/types.mdx
+++ b/fern/products/fern-def/pages/types.mdx
@@ -278,4 +278,294 @@ interface Person {
age: number;
}
```
-
\ No newline at end of file
+
+### Validation
+
+You can add validation constraints to your types to ensure data integrity and provide better error messages in generated SDKs. You can add validation rules to both type aliases and type references.
+
+### String validation
+
+String types support several validation constraints:
+
+
+ Minimum number of characters required
+
+
+
+ Maximum number of characters allowed
+
+
+
+ Regular expression pattern that the string must match
+
+
+
+ String format specification (e.g., "email", "uri", "date-time")
+
+
+#### Example: String validation on type alias
+
+```yaml
+types:
+ Email:
+ type: string
+ validation:
+ format: email
+ maxLength: 254
+
+ Username:
+ type: string
+ validation:
+ minLength: 3
+ maxLength: 20
+ pattern: "^[a-zA-Z0-9_]+$"
+
+ PhoneNumber:
+ type: string
+ validation:
+ pattern: "^\\+?[1-9]\\d{1,14}$"
+```
+
+#### Example: String validation on object properties
+
+```yaml
+types:
+ User:
+ properties:
+ email:
+ type: string
+ validation:
+ format: email
+ maxLength: 254
+ username:
+ type: string
+ validation:
+ minLength: 3
+ maxLength: 20
+ pattern: "^[a-zA-Z0-9_]+$"
+ bio:
+ type: optional
+ validation:
+ maxLength: 500
+```
+
+### Number validation
+
+Number types (including `integer`, `long`, and `double`) support validation constraints:
+
+
+ Minimum value (inclusive by default)
+
+
+
+ Maximum value (inclusive by default)
+
+
+
+ When true, the minimum value is exclusive (value must be greater than min)
+
+
+
+ When true, the maximum value is exclusive (value must be less than max)
+
+
+
+ Value must be a multiple of this number
+
+
+#### Example: Number validation on type alias
+
+```yaml
+types:
+ Age:
+ type: integer
+ validation:
+ min: 0
+ max: 150
+```
+ Price:
+ type: double
+ validation:
+ min: 0
+ exclusiveMin: true # Price must be greater than 0
+ multipleOf: 0.01 # Price must be in cents
+
+ Percentage:
+ type: double
+ validation:
+ min: 0
+ max: 100
+```
+
+#### Example: Number validation on object properties
+
+```yaml
+types:
+ Product:
+ properties:
+ name: string
+ price:
+ type: double
+ validation:
+ min: 0
+ exclusiveMin: true
+ multipleOf: 0.01
+ quantity:
+ type: integer
+ validation:
+ min: 1
+ max: 1000
+ discount:
+ type: optional
+ validation:
+ min: 0
+ max: 100
+```
+
+### Validation in generated SDKs
+
+When you add validation constraints to your Fern Definition, they are automatically enforced in generated SDKs:
+
+
+```python title="Python SDK"
+from your_api import YourApiClient
+from your_api.errors import ValidationError
+
+client = YourApiClient(api_key="your-api-key")
+
+try:
+ # This will raise a ValidationError
+ user = client.users.create(
+ email="invalid-email", # Fails email format validation
+ username="ab", # Fails minLength validation
+ age=-5 # Fails min value validation
+ )
+except ValidationError as e:
+ print(f"Validation failed: {e}")
+```
+
+```typescript title="TypeScript SDK"
+import { YourApiClient, ValidationError } from "your-api-sdk";
+
+const client = new YourApiClient({
+ apiKey: "your-api-key"
+});
+
+try {
+ // This will throw a ValidationError
+ const user = await client.users.create({
+ email: "invalid-email", // Fails email format validation
+ username: "ab", // Fails minLength validation
+ age: -5 // Fails min value validation
+ });
+} catch (error) {
+ if (error instanceof ValidationError) {
+ console.log(`Validation failed: ${error.message}`);
+ }
+}
+```
+
+```java title="Java SDK"
+import com.yourapi.YourApiClient;
+import com.yourapi.core.ValidationException;
+
+YourApiClient client = YourApiClient.builder()
+ .apiKey("your-api-key")
+ .build();
+
+try {
+ // This will throw a ValidationException
+ User user = client.users().create(CreateUserRequest.builder()
+ .email("invalid-email") // Fails email format validation
+ .username("ab") // Fails minLength validation
+ .age(-5) // Fails min value validation
+ .build());
+} catch (ValidationException e) {
+ System.out.println("Validation failed: " + e.getMessage());
+}
+```
+
+
+### Best practices
+
+
+ **Use validation to improve API reliability**: Validation constraints help catch errors early and provide clear feedback to API consumers.
+
+
+
+ **Be consistent with formats**: Use standard format values like "email", "uri", "date-time" for better interoperability.
+
+
+
+ **Document your patterns**: When using regex patterns, consider adding documentation to explain the expected format.
+
+
+```yaml
+types:
+ ProductCode:
+ docs: Product code must be 3 uppercase letters followed by 4 digits (e.g., ABC1234)
+ type: string
+ validation:
+ pattern: "^[A-Z]{3}\\d{4}$"
+```
+
+
+ **Regex escaping**: Remember to properly escape backslashes in YAML strings. Use `\\d` instead of `\d` for digit patterns.
+
+
+### Common validation patterns
+
+Here are some commonly used validation patterns:
+
+```yaml
+types:
+ # Email validation
+ Email:
+ type: string
+ validation:
+ format: email
+ maxLength: 254
+
+ # URL validation
+ WebsiteUrl:
+ type: string
+ validation:
+ format: uri
+ pattern: "^https?://"
+
+ # Phone number (international format)
+ PhoneNumber:
+ type: string
+ validation:
+ pattern: "^\\+?[1-9]\\d{1,14}$"
+
+ # Credit card number (basic format)
+ CreditCardNumber:
+ type: string
+ validation:
+ pattern: "^\\d{13,19}$"
+ minLength: 13
+ maxLength: 19
+
+ # Positive currency amount
+ Amount:
+ type: double
+ validation:
+ min: 0
+ exclusiveMin: true
+ multipleOf: 0.01
+
+ # Percentage (0-100)
+ Percentage:
+ type: double
+ validation:
+ min: 0
+ max: 100
+
+ # Port number
+ Port:
+ type: integer
+ validation:
+ min: 1
+ max: 65535
+```
\ No newline at end of file
From 6f563df8c12d4d67fad5c76f80305c4552721a27 Mon Sep 17 00:00:00 2001
From: Devin Logan
Date: Thu, 7 Aug 2025 14:16:15 -0400
Subject: [PATCH 2/3] cut down and clarify validation section
---
fern/products/fern-def/pages/types.mdx | 307 +++++++------------------
1 file changed, 87 insertions(+), 220 deletions(-)
diff --git a/fern/products/fern-def/pages/types.mdx b/fern/products/fern-def/pages/types.mdx
index 8c1289bb1..14961db99 100644
--- a/fern/products/fern-def/pages/types.mdx
+++ b/fern/products/fern-def/pages/types.mdx
@@ -279,57 +279,32 @@ interface Person {
}
```
-### Validation
-You can add validation constraints to your types to ensure data integrity and provide better error messages in generated SDKs. You can add validation rules to both type aliases and type references.
+### Validating types
-### String validation
+You can add validation constraints to your types (both aliases and references) to ensure data integrity and provide better error messages in generated SDKs:
-String types support several validation constraints:
-
-
- Minimum number of characters required
-
-
-
- Maximum number of characters allowed
-
-
-
- Regular expression pattern that the string must match
-
-
-
- String format specification (e.g., "email", "uri", "date-time")
-
-
-#### Example: String validation on type alias
-
-```yaml
+```yaml {4-6}
types:
- Email:
+ Sentence:
type: string
validation:
- format: email
- maxLength: 254
-
- Username:
- type: string
- validation:
- minLength: 3
- maxLength: 20
- pattern: "^[a-zA-Z0-9_]+$"
-
- PhoneNumber:
- type: string
- validation:
- pattern: "^\\+?[1-9]\\d{1,14}$"
+ minLength: 4
+ maxLength: 256
```
-#### Example: String validation on object properties
+
+
-```yaml
+String types support several validation constraints.
+
+```yaml {4-6, 11-13, 16-19}
types:
+ Word:
+ type: string
+ validation:
+ minLength: 2
+ maxLength: 26
User:
properties:
email:
@@ -343,64 +318,37 @@ types:
minLength: 3
maxLength: 20
pattern: "^[a-zA-Z0-9_]+$"
- bio:
- type: optional
- validation:
- maxLength: 500
```
-### Number validation
-
-Number types (including `integer`, `long`, and `double`) support validation constraints:
-
-
- Minimum value (inclusive by default)
+
+ Minimum number of characters required
-
- Maximum value (inclusive by default)
+
+ Maximum number of characters allowed
-
- When true, the minimum value is exclusive (value must be greater than min)
+
+ Regular expression pattern that the string must match
-
- When true, the maximum value is exclusive (value must be less than max)
+
+ String format specification (e.g., "email", "uri", "date-time")
-
- Value must be a multiple of this number
-
+
-#### Example: Number validation on type alias
+
-```yaml
+Number types (including `integer`, `long`, and `double`) support several validation constraints.
+
+```yaml {4-6, 12-15, 18-20}
types:
Age:
type: integer
validation:
min: 0
max: 150
-```
- Price:
- type: double
- validation:
- min: 0
- exclusiveMin: true # Price must be greater than 0
- multipleOf: 0.01 # Price must be in cents
-
- Percentage:
- type: double
- validation:
- min: 0
- max: 100
-```
-
-#### Example: Number validation on object properties
-
-```yaml
-types:
Product:
properties:
name: string
@@ -415,48 +363,71 @@ types:
validation:
min: 1
max: 1000
- discount:
- type: optional
- validation:
- min: 0
- max: 100
```
-### Validation in generated SDKs
+
+ Minimum value (inclusive by default)
+
-When you add validation constraints to your Fern Definition, they are automatically enforced in generated SDKs:
+
+ Maximum value (inclusive by default)
+
-
-```python title="Python SDK"
-from your_api import YourApiClient
-from your_api.errors import ValidationError
-
-client = YourApiClient(api_key="your-api-key")
-
-try:
- # This will raise a ValidationError
- user = client.users.create(
- email="invalid-email", # Fails email format validation
- username="ab", # Fails minLength validation
- age=-5 # Fails min value validation
- )
-except ValidationError as e:
- print(f"Validation failed: {e}")
-```
+
+ When true, the minimum value is exclusive (value must be greater than min)
+
+
+
+ When true, the maximum value is exclusive (value must be less than max)
+
+
+
+ Value must be a multiple of this number
+
-```typescript title="TypeScript SDK"
-import { YourApiClient, ValidationError } from "your-api-sdk";
+
+
-const client = new YourApiClient({
- apiKey: "your-api-key"
-});
+#### Validation in generated SDKs
+When you add validation constraints to your Fern Definition, they are automatically enforced in generated SDKs:
+
+
+```yaml {8-11, 15-17}
+types:
+ Person:
+ docs: A person represents a human being
+ properties:
+ name:
+ docs: The person's full name
+ type: string
+ validation:
+ minLength: 2
+ maxLength: 100
+ pattern: "^[A-Za-z ]+$"
+ age:
+ docs: Age in years
+ type: integer
+ validation:
+ min: 0
+ max: 150
+```
+
+
+```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 {
- // This will throw a ValidationError
- const user = await client.users.create({
- email: "invalid-email", // Fails email format validation
- username: "ab", // Fails minLength validation
- age: -5 // Fails min value validation
+ const person = await client.createPerson({
+ name: "A", // Fails minLength validation
+ age: -5, // Fails min validation
});
} catch (error) {
if (error instanceof ValidationError) {
@@ -464,108 +435,4 @@ try {
}
}
```
-
-```java title="Java SDK"
-import com.yourapi.YourApiClient;
-import com.yourapi.core.ValidationException;
-
-YourApiClient client = YourApiClient.builder()
- .apiKey("your-api-key")
- .build();
-
-try {
- // This will throw a ValidationException
- User user = client.users().create(CreateUserRequest.builder()
- .email("invalid-email") // Fails email format validation
- .username("ab") // Fails minLength validation
- .age(-5) // Fails min value validation
- .build());
-} catch (ValidationException e) {
- System.out.println("Validation failed: " + e.getMessage());
-}
-```
-
-
-### Best practices
-
-
- **Use validation to improve API reliability**: Validation constraints help catch errors early and provide clear feedback to API consumers.
-
-
-
- **Be consistent with formats**: Use standard format values like "email", "uri", "date-time" for better interoperability.
-
-
-
- **Document your patterns**: When using regex patterns, consider adding documentation to explain the expected format.
-
-
-```yaml
-types:
- ProductCode:
- docs: Product code must be 3 uppercase letters followed by 4 digits (e.g., ABC1234)
- type: string
- validation:
- pattern: "^[A-Z]{3}\\d{4}$"
-```
-
-
- **Regex escaping**: Remember to properly escape backslashes in YAML strings. Use `\\d` instead of `\d` for digit patterns.
-
-
-### Common validation patterns
-
-Here are some commonly used validation patterns:
-
-```yaml
-types:
- # Email validation
- Email:
- type: string
- validation:
- format: email
- maxLength: 254
-
- # URL validation
- WebsiteUrl:
- type: string
- validation:
- format: uri
- pattern: "^https?://"
-
- # Phone number (international format)
- PhoneNumber:
- type: string
- validation:
- pattern: "^\\+?[1-9]\\d{1,14}$"
-
- # Credit card number (basic format)
- CreditCardNumber:
- type: string
- validation:
- pattern: "^\\d{13,19}$"
- minLength: 13
- maxLength: 19
-
- # Positive currency amount
- Amount:
- type: double
- validation:
- min: 0
- exclusiveMin: true
- multipleOf: 0.01
-
- # Percentage (0-100)
- Percentage:
- type: double
- validation:
- min: 0
- max: 100
-
- # Port number
- Port:
- type: integer
- validation:
- min: 1
- max: 65535
-```
\ No newline at end of file
+
\ No newline at end of file
From b0618e6af2a41125ce5d6eb98f42ec3aff4ae61e Mon Sep 17 00:00:00 2001
From: Devin Logan
Date: Thu, 7 Aug 2025 14:23:11 -0400
Subject: [PATCH 3/3] Condense further
---
fern/products/fern-def/pages/types.mdx | 102 +++++++++++--------------
1 file changed, 46 insertions(+), 56 deletions(-)
diff --git a/fern/products/fern-def/pages/types.mdx b/fern/products/fern-def/pages/types.mdx
index 14961db99..f623832d7 100644
--- a/fern/products/fern-def/pages/types.mdx
+++ b/fern/products/fern-def/pages/types.mdx
@@ -282,19 +282,56 @@ interface Person {
### Validating types
-You can add validation constraints to your types (both aliases and references) to ensure data integrity and provide better error messages in generated SDKs:
+You can add validation constraints to your types (both aliases and references) to ensure data integrity. Validation constracts are automatically enforced in generated SDKs.
-```yaml {4-6}
+
+```yaml {8-11, 15-17}
types:
- Sentence:
- type: string
- validation:
- minLength: 4
- maxLength: 256
+ Person:
+ docs: A person represents a human being
+ properties:
+ name:
+ docs: The person's full name
+ type: string
+ validation:
+ minLength: 2
+ maxLength: 100
+ pattern: "^[A-Za-z ]+$"
+ age:
+ docs: Age in years
+ type: integer
+ validation:
+ min: 0
+ max: 150
```
+
+
+
+```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}`);
+ }
+}
+```
+
-
+
String types support several validation constraints.
@@ -338,7 +375,7 @@ types:
-
+
Number types (including `integer`, `long`, and `double`) support several validation constraints.
@@ -388,51 +425,4 @@ types:
-#### Validation in generated SDKs
-When you add validation constraints to your Fern Definition, they are automatically enforced in generated SDKs:
-
-
-```yaml {8-11, 15-17}
-types:
- Person:
- docs: A person represents a human being
- properties:
- name:
- docs: The person's full name
- type: string
- validation:
- minLength: 2
- maxLength: 100
- pattern: "^[A-Za-z ]+$"
- age:
- docs: Age in years
- type: integer
- validation:
- min: 0
- max: 150
-```
-
-
-```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}`);
- }
-}
-```
-
\ No newline at end of file