Skip to content

enable validation #69

@evbo

Description

@evbo

Could a NewOption be added to configure a custom validation function to run after the struct is instantiated?

This would allow us to then run https://docs.rs/crate/validator/0.20.0 inside of new

A common pattern is to enforce private access to struct fields so that new enforces non-empty string fields or collections.

Although it's possible to make new private and then write your own new_valid that calls new, the problem is you then have to add all of the arguments yourself to new_valid, which sort of is the intent of using derive-new to begin with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions