How I can I avoid having validation for update while having it for create? For instance:
I wish to have an image field to have presence validation on create. But want to avoid it in edit and assume the previous value in case of no change.
Note: I am using Padrino.
In Sequel, validations are generally done at the instance level using the validation_helpers plugin. So you just use a standard ruby conditional if you only want to validate it for new objects and not for existing ones:
plugin :validation_helpers
def validate
super
validates_presence :image if new?
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With