Re: validation_helpers

2023-10-29 Thread Jeremy Evans
On Sun, Oct 29, 2023 at 3:40 AM bee...@gmail.com  wrote:

> For some reason I can't get the validation_helpers to load:
>
>
> In the models loader:
> *Sequel::Model.plugin :validation_helpers*
>
> Models are loaded after helpers.  Inside the class that's been working:
> *plugin :validation_helpers*
>
> Error:
> *undefined method `before_validation' for Carrier:Class*
>
> It seems like everything is in order, however it isn't loading.  What
> should I be checking?
>

Sequel doesn't support that by default.  However, you can use the
hook_class_methods plugin if you want that feature.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/CADGZSSefRwJ4i7AEzR03z5NLTg5Es0XD0sfFXSg658NJNtvTVA%40mail.gmail.com.


Re: validation_helpers

2023-10-29 Thread Michael Granger

On 29 Oct 2023, at 11:50, Marcelo wrote:

I don't see the *validation_helpers* plugin adding a 
*before_validation*

class method:
https://sequel.jeremyevans.net/rdoc-plugins/classes/Sequel/Plugins/ValidationHelpers.html

You can see in the docs how this plugin only adds some *validates_**
methods, which should be called inside the model's *validate* method.

This *before_validation* class method is something that exists in
Rails/ActiveRecord; I'm not sure it exists in Sequel.


Validations are in the base Model class:

  
http://sequel.jeremyevans.net/rdoc/files/README_rdoc.html#label-Model+Validations

As are the validation hooks (including `before_validation`), though 
they're instance methods not class methods:


  
http://sequel.jeremyevans.net/rdoc/files/doc/model_hooks_rdoc.html#label-Available+Hooks

The plugin just contains methods that help with common validation tasks.

--
Michael Granger 

--
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/0FEF50CD-CDAC-4B86-872D-E3C44A4F4036%40gmail.com.


Re: validation_helpers

2023-10-29 Thread bee...@gmail.com
OK, I've turned that into a method.  And it works now.  I thought it might 
have followed the *before_* situations that *Sinatra* follows.  

As well, is *Object.valid? *a alias for *Object.validate* as it's not 
apparent due to the *super*.  The individual validates_ methods were fine.  
It was suggested that I include this plugin after *helpers* and before 
*models*.  

Thank you.  

On Sunday, October 29, 2023 at 6:50:26 AM UTC-4 Marcelo wrote:

> I don't see the *validation_helpers* plugin adding a *before_validation* 
> class method:
>
> https://sequel.jeremyevans.net/rdoc-plugins/classes/Sequel/Plugins/ValidationHelpers.html
>
> You can see in the docs how this plugin only adds some *validates_** 
> methods, which should be called inside the model's *validate* method.
>
> This *before_validation* class method is something that exists in 
> Rails/ActiveRecord; I'm not sure it exists in Sequel.
>
> On Sunday, October 29, 2023 at 11:40:32 AM UTC+1 bee...@gmail.com wrote:
>
>> For some reason I can't get the validation_helpers to load:
>>
>>
>> In the models loader:
>> *Sequel::Model.plugin :validation_helpers*
>>
>> Models are loaded after helpers.  Inside the class that's been working:
>> *plugin :validation_helpers*
>>
>> Error:
>> *undefined method `before_validation' for Carrier:Class*
>>
>> It seems like everything is in order, however it isn't loading.  What 
>> should I be checking?
>>
>> Cheers
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/42ec4205-5cfa-4703-a893-42aac74f3e38n%40googlegroups.com.


Re: validation_helpers

2023-10-29 Thread Marcelo
I don't see the *validation_helpers* plugin adding a *before_validation* 
class method:
https://sequel.jeremyevans.net/rdoc-plugins/classes/Sequel/Plugins/ValidationHelpers.html

You can see in the docs how this plugin only adds some *validates_** 
methods, which should be called inside the model's *validate* method.

This *before_validation* class method is something that exists in 
Rails/ActiveRecord; I'm not sure it exists in Sequel.

On Sunday, October 29, 2023 at 11:40:32 AM UTC+1 bee...@gmail.com wrote:

> For some reason I can't get the validation_helpers to load:
>
>
> In the models loader:
> *Sequel::Model.plugin :validation_helpers*
>
> Models are loaded after helpers.  Inside the class that's been working:
> *plugin :validation_helpers*
>
> Error:
> *undefined method `before_validation' for Carrier:Class*
>
> It seems like everything is in order, however it isn't loading.  What 
> should I be checking?
>
> Cheers
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/4ba122fc-8070-422f-a783-2e9b1b816777n%40googlegroups.com.


validation_helpers

2023-10-29 Thread bee...@gmail.com
For some reason I can't get the validation_helpers to load:


In the models loader:
*Sequel::Model.plugin :validation_helpers*

Models are loaded after helpers.  Inside the class that's been working:
*plugin :validation_helpers*

Error:
*undefined method `before_validation' for Carrier:Class*

It seems like everything is in order, however it isn't loading.  What 
should I be checking?

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/0309b803-c41d-4129-9231-1ed58d326e35n%40googlegroups.com.


Alternative validation_helpers syntax feedback

2009-10-20 Thread Jeremy Evans

I've got a working implementation for a plugin that allows an
alternative syntax for the validation_helpers plugin's methods (http://
pastie.org/662251.txt):

def validate
  validates do
name do
  presence
  max_length 10
end
date do
  format %r{\d\d/\d\d/\d\d\d\d}
end
number do
  presence
  integer
end
  end
end

This syntax is a lot more verbose than the standard syntax, but I have
a fairly specific use case in mind.  The project I'm working on
currently has a table with about 80-90 columns all with validation
requirements.  Using the standard syntax, it's difficult to see what
validations apply to each column, since the validations are sorted by
type of validation (e.g. presence, max_length), not by column.

This type of syntax allows me to basically print out the validation
code, sit with project manager, and make sure all desired validations
are being enforced.  I think it is more natural to think of all
validations for a given column, versus all columns with a certain
validation type.

Of course, if you only have a few columns, this syntax is just more
verbose.  This syntax really only has an advantage when you have many
columns and it is difficult to look at your validate method and see
what validations are being applied to what columns.

Anyway, I'd like to get some feedback as to whether people think this
should be added to the plugins that ship with Sequel.

Also, I'd like to thank Rich Kilmer for the general idea of this type
of syntax.  I got the idea from his LoneStar RubyConf presentation on
Encoding Domains.

Jeremy
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sequel-talk group.
To post to this group, send email to sequel-talk@googlegroups.com
To unsubscribe from this group, send email to 
sequel-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~--~~~~--~~--~--~---