Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guess we doin V now (a new validation framework) #459

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open

Conversation

Tinche
Copy link
Member

@Tinche Tinche commented Nov 22, 2023

No description provided.

@Tinche
Copy link
Member Author

Tinche commented Nov 23, 2023

@petergaultney this is very much experimental and a work-in-progress at this point ;)

@Tinche Tinche changed the title Guess we doin V now Guess we doin V now (a new validation framework) Nov 23, 2023
@Tinche Tinche force-pushed the tin/so-much-v branch 2 times, most recently from 18fb2b8 to 56824bf Compare November 23, 2023 23:54
@MicaelJarniac
Copy link
Contributor

Is there an issue, or anything, describing what's going on?

@MicaelJarniac
Copy link
Contributor

MicaelJarniac commented Nov 30, 2023

From a quick glance, this seems to be the new feature:

    hook = customize(
        c,
        Small,
        V((fs := f(Small)).a).ensure(greater_than(10)),
        V(fs.b).ensure(len_between(0, 10)),
    )

I'm pretty clueless as to what's going on, but may I suggest also supporting something like:

    hook = customize(
        c,
        Small,
        V((fs := f(Small)).a) > 10 and
        0 <= len(V(fs.b)) < 10,
    )

By overwriting the __gt__, __len__, __and__, and such operators, to construct these validations in a more fluent way?

This would be similar to how libs like SQLAlchemy handle some queries.

These operators could return the same that .ensure(greater_than(10)) would return, for example, and not bool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants