-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
3,039 additions
and
1,194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
/** | ||
********************************************************************************* | ||
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp | ||
* www.coldbox.org | www.luismajano.com | www.ortussolutions.com | ||
******************************************************************************** | ||
* Copyright since 2020 by Ortus Solutions, Corp | ||
* www.ortussolutions.com | ||
* --- | ||
*/ | ||
component { | ||
|
||
// Module Properties | ||
this.title = "validation"; | ||
this.author = "Luis Majano"; | ||
this.webURL = "http://www.ortussolutions.com"; | ||
this.description = "This module provides server-side validation to ColdBox applications"; | ||
this.version = "@build.version@[email protected]@"; | ||
// If true, looks for views in the parent first, if not found, then in the module. Else vice-versa | ||
this.viewParentLookup = true; | ||
// If true, looks for layouts in the parent first, if not found, then in module. Else vice-versa | ||
this.layoutParentLookup = true; | ||
this.title = "validation"; | ||
this.author = "Luis Majano"; | ||
this.webURL = "https://www.ortussolutions.com"; | ||
this.description = "This module provides server-side validation to ColdBox applications"; | ||
this.version = "@build.version@[email protected]@"; | ||
|
||
// Model Namespace | ||
this.modelNamespace = "cbvalidation"; | ||
this.modelNamespace = "cbvalidation"; | ||
// CF Mapping | ||
this.cfmapping = "cbvalidation"; | ||
// Auto-map models | ||
this.autoMapModels = true; | ||
this.cfmapping = "cbvalidation"; | ||
// Helpers | ||
this.applicationHelper = [ "helpers/Mixins.cfm" ]; | ||
|
||
// Module Dependencies That Must Be Loaded First, use internal names or aliases | ||
this.dependencies = [ "cbi18n" ]; | ||
// ColdBox Static path to validation manager | ||
|
@@ -32,95 +29,37 @@ component { | |
*/ | ||
function configure(){ | ||
// Mixin our own methods on handlers, interceptors and views via the ColdBox UDF Library File setting | ||
arrayAppend( | ||
controller.getSetting( "ApplicationHelper" ), | ||
"#moduleMapping#/models/Mixins.cfm" | ||
); | ||
settings = { | ||
manager : this.COLDBOX_VALIDATION_MANAGER, | ||
// i18nResource = "", | ||
sharedConstraints : {} | ||
}; | ||
} | ||
|
||
/** | ||
* Fired when the module is registered and activated. | ||
*/ | ||
function onLoad(){ | ||
var configSettings = controller.getConfigSettings(); | ||
// parse parent settings | ||
parseParentSettings(); | ||
// Did you change the validation manager? | ||
if ( configSettings.validation.manager != this.COLDBOX_VALIDATION_MANAGER ) { | ||
if ( variables.settings.manager != this.COLDBOX_VALIDATION_MANAGER ) { | ||
binder | ||
.map( | ||
alias = "validationManager@cbvalidation", | ||
force = true | ||
) | ||
.to( configSettings.validation.manager ) | ||
.to( variables.settings.manager ) | ||
.asSingleton(); | ||
} | ||
// setup shared constraints | ||
wirebox | ||
.getInstance( "validationManager@cbvalidation" ) | ||
.setSharedConstraints( configSettings.validation.sharedConstraints ); | ||
.setSharedConstraints( variables.settings.sharedConstraints ); | ||
} | ||
|
||
/** | ||
* Fired when the module is unregistered and unloaded | ||
*/ | ||
function onUnload(){ | ||
var appHelperArray = controller.getSetting( "ApplicationHelper" ); | ||
var mixinToRemove = "#moduleMapping#/models/Mixins.cfm"; | ||
var mixinIndex = arrayFindNoCase( appHelperArray, mixinToRemove ); | ||
|
||
// If the mixin is in the array | ||
if ( mixinIndex ) { | ||
// Remove it | ||
arrayDeleteAt( appHelperArray, mixinIndex ); | ||
// Arrays passed by value in Adobe CF | ||
controller.setSetting( "ApplicationHelper", appHelperArray ); | ||
} | ||
} | ||
|
||
/** | ||
* Prepare settings and returns true if using i18n else false. | ||
*/ | ||
private function parseParentSettings(){ | ||
/** | ||
Sample : | ||
validation = { | ||
manager = "class path" // if overriding | ||
sharedConstraints = { | ||
name = { | ||
field = { constraints here } | ||
} | ||
} | ||
} | ||
*/ | ||
// Read parent application config | ||
var oConfig = controller.getSetting( "ColdBoxConfig" ); | ||
var validationDSL = oConfig.getPropertyMixin( | ||
"validation", | ||
"variables", | ||
structNew() | ||
); | ||
var configStruct = controller.getConfigSettings(); | ||
|
||
// Default Config Structure | ||
configStruct.validation = { | ||
manager : this.COLDBOX_VALIDATION_MANAGER, | ||
sharedConstraints : {} | ||
}; | ||
|
||
// manager | ||
if ( structKeyExists( validationDSL, "manager" ) ) { | ||
configStruct.validation.manager = validationDSL.manager; | ||
} | ||
// shared constraints | ||
if ( structKeyExists( validationDSL, "sharedConstraints" ) ) { | ||
structAppend( | ||
configStruct.validation.sharedConstraints, | ||
validationDSL.sharedConstraints, | ||
true | ||
); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name":"ColdBox Validation", | ||
"author":"Ortus Solutions <[email protected]>", | ||
"version":"3.0.0", | ||
"version":"3.1.0", | ||
"location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbvalidation/@build.version@/[email protected]@.zip", | ||
"slug":"cbvalidation", | ||
"type":"modules", | ||
|
@@ -32,8 +32,11 @@ | |
], | ||
"scripts":{ | ||
"release":"recipe build/release.boxr", | ||
"format":"cfformat run models/,test-harness/tests/,*.cfc --overwrite", | ||
"format:watch":"cfformat watch models/,test-harness/tests/,*.cfc ./.cfformat.json", | ||
"format:check":"cfformat check models/,test-harness/tests/,*.cfc" | ||
"format":"cfformat run interfaces,models/,test-harness/tests/,ModuleConfig.cfc --overwrite", | ||
"format:watch":"cfformat watch interfaces,models/,test-harness/tests/,ModuleConfig.cfc ./.cfformat.json", | ||
"format:check":"cfformat check interfaces,models/,test-harness/tests/,ModuleConfig.cfc" | ||
}, | ||
"installPaths":{ | ||
"cbi18n":"modules/cbi18n/" | ||
} | ||
} |
Oops, something went wrong.