mojotech / mojotech/json-type-validation
Support custom field name for validation
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 154
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
Sometimes the convention from the server in json doesn't directly map to the styles on the front end. For example, data from the API may be in snake_case when the javascript is using camelCase. Since this library is already parsing and converting raw json to correctly formed typescript compatible types, it seems this would be a great layer to adapt to these differences.
For example, something like the following syntax would be ideal:
const userDecoder: Decoder<User> = object({
firstName: string('first_name'),
lastName: string('last_name'),
username: string()
)};
where the the string decoder has an optional string parameter.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the current string and object decoder entry points and inspect how raw JSON fields are mapped to TypeScript properties. Use the proposed firstName/first_name example to define the supported optional field-name syntax, then add coverage showing that snake_case input validates against camelCase fields while existing username behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100