Fork me on GitHub
#malli
<
2019-10-28
>
eskos13:10:23

Hey so I feel really dumb but how would I make a malli schema which validates that I have a non-empty string 😅 I’m thinking something like [:and string? [:not= blank?]] but there’s no blank? predicate support…

eskos13:10:46

blank? does string check internally as well so it doesn’t need to be :and schema but anyhoos…

ikitommi13:10:18

@suomi.esko You can use any predicate with :fn, either: [:fn str/blank?] (local, fast) or [:fn 'str/blank?] (portable)

eskos14:10:31

@ikitommi Seems to work for the positive case, but I really do want to test the negation of that and I can’t seem to get it to work, or at least :not= isn’t what I should use. I think there isn’t a complementing predicate yet? 🙂

ikitommi14:10:44

[:and string? some?] or [:fn {:error/message "should be non-empty string"} '(complement str/blank?)]?

ikitommi14:10:59

could be :not ....

eskos14:10:53

latter works though

eskos14:10:15

former indeed does not, some? is effectively “not nil” check