-
Notifications
You must be signed in to change notification settings - Fork 52
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
Custom regex arguments in validations. #106
Comments
what about That way it's not specific, in case you want to chain. |
I like the above approach but for the conversation I'll add that you can currently register a custom validator like so: module RubyMotionQuery
class Validation
class << self
IS_DAVE = Regexp.new('^Dave$')
@@validation_methods[:is_dave] = lambda do |value, opts|
Validation.regex_match?(value, IS_DAVE)
end
end
end
end Then rmq.append(UITextField, :user).validates(:is_dave)
rmq.validation.valid?("Dave", :is_dave) #=> true |
@vaughankg maybe rmq.validation.add_validator(:is_dave) do |value, opts|
# Whatever here
true
end for a convenient way to add custom validators? |
Looks good. |
Maybe something like this. Would also help eliminate the problem of trying to build the ultimate regex!
The text was updated successfully, but these errors were encountered: