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

add :allow-blank, validate-all #10

Closed

Conversation

vindarel
Copy link
Contributor

WDYT?

It's shorter than "||" and "&&". It seems to be working OK.

(clavier::validate-all (list  :ALLOW-BLANK (clavier:len :min 3) (clavier:len :min 4)) "a")
NIL
("Length of \"a\" is less than 3" "Length of \"a\" is less than 4")


(clavier::validate-all (list  :ALLOW-BLANK (clavier:len :min 3) (clavier:len :min 4)) "")
T
NIL

for #7

@vindarel vindarel force-pushed the vindarel/allow-blank-validate-all branch from 2435c7a to 3e8f504 Compare February 27, 2024 16:06
@mmontone
Copy link
Owner

My problem with this is that I think validate-all is equivalent to a generalized and (make the and-validator work with several arguments instead of two). is it not? Also for or-validator . I would accept a pull request for that.

I prefer not having the validate-all and the keyword syntax so as to maintain simplicity and consistency (in my view).

@mmontone
Copy link
Owner

Remember you can have that validate-all function as part of your project, outside of clavier . So you can still have your cake if you want that, for your project, despite my rejection.

I mention this because sometimes we forget we can do things from the outside.

@mmontone mmontone closed this Feb 27, 2024
@vindarel
Copy link
Contributor Author

vindarel commented Feb 27, 2024

I plan to expose this api to end-users (developers). They define a list of validators for their form fields. So for me it's going to be required to have a simpler syntax than

|| (blank) 
    && (len)

for such a common need. I prefer them to write

(list :allow-blank (len))

I want field declarations to be as simple as in Django.

Also, it is quite logical to validate many validators, isn't it? (and "validator-collection" isn't simple?) My app already had to add the validate-all function (again, for an HTML form).

I mention this because sometimes we forget we can do things from the outside.

yes, quite the contrary, often a lisper cooks his own food, it's too simple to not contribute!! ;)

I'll think through the needs more.


is it not?

I have to check… :allow-blank kind of does a early exit, I don't think the and validator allows that?

@mmontone
Copy link
Owner

I plan to expose this api to end-users (developers). They define a list of validators for their form fields. So for me it's going to be required to have a simpler syntax than

|| (blank) 
    && (len)

for such a common need. I prefer them to write

(list :allow-blank (len))

I want field declarations to be as simple as in Django.

Ok. But I see that as part of your project. I prefer Clavier to only give you the building blocks in a consistent way.

Also, it is quite logical to validate many validators, isn't it? (and "validator-collection" isn't simple?) My app already had to add the validate-all function (again, for an HTML form).

Yes. But my point is "validate many validators" is equivalent to an and validators with all the many validators.

I mention this because sometimes we forget we can do things from the outside.

yes, quite the contrary, often a lisper cooks his own food, it's too simple to not contribute!! ;)

I'll think through the needs more.

is it not?

I have to check… :allow-blank kind of does a early exit, I don't think the and validator allows that?

It does not. My point was about "validate many validators" being equivalent to an and validator. Again, I see :allow-blank as part of your project "syntax".

@mmontone
Copy link
Owner

Ok. I see your point of validate-all combined with the early exit of :allow-blank . But I still prefer not to have it in Clavier.

@vindarel
Copy link
Contributor Author

Understood, and so be it. I wanted to extract that feature from my app, but I'm not happy with a fork or a trivial library. Let's see…

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.

None yet

2 participants