Skip to content

Commit 5e1497b

Browse files
committed
- The way custom validators are retrieved so they are ColdBox 7+ compatible
1 parent 0efc5f9 commit 5e1497b

File tree

6 files changed

+21
-22
lines changed

6 files changed

+21
-22
lines changed

box.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,16 @@
4646
"format":"cfformat run helpers,interfaces,models,test-harness/tests/,ModuleConfig.cfc --overwrite",
4747
"format:watch":"cfformat watch helpers,interfaces,models,test-harness/tests/,ModuleConfig.cfc ./.cfformat.json",
4848
"format:check":"cfformat check helpers,interfaces,models,test-harness/tests/,ModuleConfig.cfc ./.cfformat.json",
49-
"install:dependencies":"install && cd test-harness && install"
49+
"install:dependencies":"install && cd test-harness && install",
50+
"start:lucee" : "server start [email protected]",
51+
"start:2018" : "server start [email protected]",
52+
"start:2021" : "server start [email protected]",
53+
"stop:lucee" : "server stop [email protected]",
54+
"stop:2018" : "server stop [email protected]",
55+
"stop:2021" : "server stop [email protected]",
56+
"logs:lucee" : "server log [email protected] --follow",
57+
"logs:2018" : "server log [email protected] --follow",
58+
"logs:2021" : "server log [email protected] --follow"
5059
},
5160
"installPaths":{
5261
"cbi18n":"modules/cbi18n/"

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717

1818
### Changed
1919

20+
- The way custom validators are retrieved so they are ColdBox 7+ compatible
2021
- `pr` github action now just does format checks to avoid issues with other repos.
2122
- Consolidated Adobe 2021 scripts into the server scripts
2223

models/ValidationManager.cfc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ component accessors="true" serialize="false" singleton {
344344
return wirebox.getInstance( coreValidators[ arguments.validatorType ] );
345345
}
346346

347-
// Else switch checks
348347
switch ( arguments.validatorType ) {
349348
// Custom Validator
350349
case "validator": {
@@ -353,15 +352,9 @@ component accessors="true" serialize="false" singleton {
353352
}
354353
return wirebox.getInstance( arguments.validationData );
355354
}
356-
// See if it's a WireBox Mapping
355+
// Delegate to WireBox
357356
default: {
358-
if ( wirebox.getBinder().mappingExists( validatorType ) ) {
359-
return wirebox.getInstance( validatorType );
360-
}
361-
throw(
362-
message = "The validator you requested #arguments.validatorType# is not a valid validator",
363-
type = "ValidationManager.InvalidValidatorType"
364-
);
357+
return wirebox.getInstance( validatorType );
365358
}
366359
}
367360
}

test-harness/box.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
"private":true,
66
"description":"",
77
"dependencies":{
8-
"coldbox":"^6.0.0",
98
"cbi18n":"^3.0.0",
109
"testbox":"*",
11-
"cbdebugger":"^3.5.0+64"
10+
"coldbox":"^6"
1211
},
1312
"installPaths":{
14-
"coldbox":"coldbox/",
1513
"testbox":"testbox/",
1614
"cbi18n":"modules/cbi18n/",
17-
"cbdebugger":"modules/cbdebugger/"
15+
"coldbox":"coldbox/"
1816
}
1917
}

test-harness/layouts/Main.cfm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<cfoutput>
22
<h1>Module Tester</h1>
33
<div>
4-
#renderView()#
4+
#view()#
55
</div>
66
</cfoutput>

test-harness/tests/specs/ValidationManagerTest.cfc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,19 @@ component extends="coldbox.system.testing.BaseTestCase" appMapping="/root" {
4747
assertEquals( 0, results.getErrorCount() );
4848
} );
4949

50-
5150
it( "can process rules with custom validators from a wirebox mapping", function(){
5251
var results = getInstance( "cbvalidation.models.result.ValidationResult" );
53-
var mockValidator = prepareMock( getInstance( "tests.resources.MockValidator" ) ).$(
52+
var mockValidator = prepareMock( manager.getWirebox().getInstance( "tests.resources.MockValidator" ) ).$(
5453
"validate",
5554
true
5655
);
5756
var mockRule = { "tests.resources.MockValidator" : { customField : "hi" } };
5857
var mock = createStub().$( "getName", "luis" );
59-
6058
manager.processRules(
61-
results = results,
62-
rules = mockRule,
63-
target = mock,
64-
field = "name"
59+
results : results,
60+
rules : mockRule,
61+
target : mock,
62+
field : "name"
6563
);
6664
assertTrue(
6765
mockValidator.$once( "validate" ),

0 commit comments

Comments
 (0)