I am working on a project that will take custom validations on models and translate them into javascript to be run on the client side. We are currently passing in the model, and the validation method (as an UnboundMethod ).
JStranslator(model, Validator.instance_method(:validate))
What I want is to get all the UnboundMethods that get used for validating the model because our translator leverages the AST representation of the methods (using 'live-ast'), therefore the model_name.validators will not work (it returns an array I think). I need to get all custom defined validation methods that are defined inside the model itself as well as all validators the model uses.
Validations are stored as callbacks, so you may want to play around with those:
Model._validate_callbacks # do something
Resources:
Happy to help more if you get stuck.