Skip to content
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

Should validation make model elements required? #12

Closed
Guite opened this issue Jul 15, 2011 · 2 comments
Closed

Should validation make model elements required? #12

Guite opened this issue Jul 15, 2011 · 2 comments

Comments

@Guite
Copy link
Owner

Guite commented Jul 15, 2011

Context

We can add validation rules to require modeling elements in certain situations.

One example which is already included: as soon as the model contains at least one join relation, validation ensures that the controller layer has an ajax controller (for handling the auto completion requests during editing).

Possible feature

We could do this also for other things. Possible examples:

  • if there are upload fields: require a filepath modvar for defining the base path
  • if there are modvars: require a custom action named config
  • if there is a view action: require an integer modvar for defining the page size

Benefits

Generator templates would become easier. For example creating the config function would need less separate template logic in addition to other actions. The generator would not have to "guess" some things (like for example which controller contains the config action) as they are explicitely modeled.

Disadvantages

A little more effort during modeling.
Also this does not push convention over configuration.

Your feedback

Any opinions about that?

@rallek
Copy link

rallek commented Aug 19, 2013

I like the idea to have some automatic fields or validation. This would make it much easier for a non programmer to create modules with variables.

For example: If you add as a default value a #my_default_value,90# entry, automatically a variable with the name my_default_value with the default of "90" will be created and used inside the template. see #308 and #264

@Guite
Copy link
Owner Author

Guite commented Dec 28, 2016

The better way is that required elements are automatically added as part of the generator workflow. A so-called model-to-model transformation is already doing that for many things, like the workflow state field, several module vars for images etc.
This approach avoids modeling efforts and also keeps the generator templates clean.
Rescheduled for 0.7.1 to review remaining validation rules which require things which could be done automatically instead. One example is that several string fields with certain flags (like language, locale, country, and so on) require activating the nospace flag, too. Replace such requirements by automatic model enhancement.

@Guite Guite closed this as completed in 3e1505f Jan 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants