Garet's avatar
Level 3

Naming convention for set of validation request rules

Hello there,

As you probably know, custom validation rules are by default stored in \app\Rules\

I am allowing a user to upload a file and the file must pass certain validations. However, I also allow the user to zip the file into an archive and upload the archived zip file. So I created a set of validation rules which extract the files from the zip archive, and then test them for certain conditions.

For example, I created a rule which says a zip file can't contain more than X number of files. I created another one which says the contents of the zip file must match a particular mime type.

I am unsure of what naming conventions to use for my rules.

First idea:

\app\Rules\ZipEncoding
\app\Rules\ZipMaxFiles
\app\Rules\ZipMimeTypes
\app\Rules\ZipMinFiles
\app\Rules\ZipValid

Second idea:

\app\Rules\Zip\Encoding
\app\Rules\Zip\MaxFiles
\app\Rules\Zip\MimeTypes
\app\Rules\Zip\MinFiles
\app\Rules\Zip\Valid

Third idea:

\app\Rules\Zip\ZipEncoding
\app\Rules\Zip\ZipMaxFiles
\app\Rules\Zip\ZipMimeTypes
\app\Rules\Zip\ZipMinFiles
\app\Rules\Zip\ZipValid

Which naming convention and organisation structure do you prefer?

Thanks,

0 likes
1 reply
aleahy's avatar
aleahy
Best Answer
Level 25

The correct answer is which one makes the most senst to you - there is no wrong answer here.

However I like the third one because it groups them into a specific folder, and you can still be aware it refers to a zip validation rule when you import the class.

2 likes

Please or to participate in this conversation.