aafre / aafre/resume-builder

Add Core Logic for Section Length Validation

Open
#106 3 comments 0 reactions 1 assignee Claimed by @harshsingh2304 View on GitHub
Dominant language
TypeScript
Stars
6
Forks
15
Avg merge
7d 22h
Merged PRs (30d)
2

Description

Breaking down #13 into parts - this is the first sub-task for setting up the core of the validation feature.

This is to create the foundational, non-API logic for validating resume section lengths. This involves adding the configuration and a helper function that will perform the checks.

For context, this logic will be used by an API endpoint (to be created in a future task) that supports a two-step validation flow:

- Real-time checks (e.g., when a user clicks away from a field), where the frontend will send the full YAML document for validation.
- A final check before a user generates a resume, which also validates the full document as a final safety measure.

**Acceptance Criteria:**

- [ ] **Add a Flexible Configuration Dictionary**
- In [`app.py`](https://github.com/aafre/resume-builder/blob/main/app.py), create a new `RECOMMENDED_LENGTHS` dictionary. This configuration will drive all validation using a prioritised rule system:
1. **By Name (Overrides):** The `by_name` key sets a specific length for a section with an exact `name` (e.g., "Summary"). This rule must take the highest priority.
2. **By Type (Defaults):** The `by_type` key sets a default length for all sections of a certain `type` (e.g., all `text` sections). This is the fallback if no `by_name` override is found. You can find all supported types documented in the [advanced section](https://github.com/aafre/resume-builder/tree/main?tab=readme-ov-file#advanced-usage) of the README.
- Here is an example structure to follow:
```python
RECOMMENDED_LENGTHS = {
# Priority 1: Check for a specific section name for overrides.
'by_name': {
'Summary': 1000,
'Professional Profile': 1000, # Handles common variations
},
# Priority 2: If no name matches, fall back to the section's type.
'by_type': {
# Default for any simple text block
'text': 1500,

# Applied to each bullet point in a list
'bulleted-list': 250,

# Applied to each skill in a horizontal list
'inline-list': 50,

# Special key to target the 'description' field within each 'experience' item
'experience.description': 1200,
}
}
```

- [ ] **Create a Validation Helper Function**
- Implement a new, pure Python function, e.g., `validate_section_lengths(data, config)`.
- It should take parsed YAML data and the config dictionary as arguments.
- It must dynamically iterate through sections and handle the different content structures of types like `text`, `bulleted-list`, and `experience`, applying the length limits from the config.
- It should return a `list` of warning objects for any validation failures.

> **Note:** This task does **not** involve creating a Flask route or handling web requests. We are only building the reusable core logic in this step.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.