dry-rb / dry-logic

Predicate logic with rule composition
https://dry-rb.org/gems/dry-logic/
MIT License
179 stars 66 forks source link

uuid? predicate #43

Closed zubin closed 5 years ago

zubin commented 6 years ago

UUIDs are widely used. Would you be open to adding a built-in predicate; something like this?

require 'uuidtools'

predicate(:uuid?) do |value|
  UUIDTools::UUID.parse(value).valid?
rescue ArgumentError, TypeError
  false
end

I'm happy to make a PR with tests if the idea is accepted.