Skip to content

Conversation

@sj26
Copy link
Contributor

@sj26 sj26 commented Jul 11, 2024

I found I needed to validate a set of values coming into a field, like this:

field :slices do
  argument :uuids, [String], validates: { all: { format: { with: UUID::REGEXP } } } }
end

I thought an all validator which composes the other validators might be a good idea. What do you think? This is a rough spike to demonstrate the idea and see if it might work.

@rmosolgo
Copy link
Owner

Yeah, I dig it! And it looks like all: ... basically takes any of the existing validation configs and applies it to each item, is that correct? Very cool.

@sj26
Copy link
Contributor Author

sj26 commented Jul 11, 2024

Yeah, neat!

I shipped this in our api yesterday. I’d love to land it here upstream. How far do you reckon it is? I’ll get the test suite passing. And maybe some more specs around the edges?

@sj26 sj26 force-pushed the validates-all branch 2 times, most recently from 611edec to 65a5b5d Compare July 11, 2024 23:39
@sj26
Copy link
Contributor Author

sj26 commented Jul 12, 2024

Okay, I think that's a reasonable balance of coverage, and some docs. The remaining CI failures look unrelated.

What do you reckon?

@rmosolgo rmosolgo modified the milestones: 2.3.7, 2.3.8 Jul 12, 2024
@rmosolgo
Copy link
Owner

LGTM! Thanks again for this improvement.

@rmosolgo rmosolgo merged commit 337eaa3 into rmosolgo:master Jul 12, 2024
@sj26 sj26 deleted the validates-all branch July 12, 2024 22:46
@sj26
Copy link
Contributor Author

sj26 commented Jul 31, 2024

Thanks! We're using it in production, works great 🎉

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