Skip to content

Commit 93ce81e

Browse files
committed
Merge branch 'development'
2 parents 75cccaf + f08a83e commit 93ce81e

24 files changed

+319
-150
lines changed

.cfconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2+
"adminPassword" : "coldbox",
23
"debuggingEnabled":true,
34
"debuggingReportExecutionTimes":false,
45
"disableInternalCFJavaComponents":false,
56
"inspectTemplate":"always",
67
"requestTimeout":"0,0,0,90",
7-
"robustExceptionEnabled":true
8-
}
8+
"robustExceptionEnabled":true,
9+
}

.github/workflows/ci.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111
MODULE_ID: cbvalidation
1212

1313
jobs:
14-
#############################################
14+
#############################################
1515
# Tests First baby! We fail, no build :(
1616
#############################################
1717
tests:
@@ -20,7 +20,7 @@ jobs:
2020
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
2121

2222
#############################################
23-
# Build Module
23+
# Build
2424
#############################################
2525
build:
2626
name: Build & Publish
@@ -38,6 +38,15 @@ jobs:
3838
distribution: "adopt"
3939
java-version: "11"
4040

41+
- name: Cache CommandBox Dependencies
42+
uses: actions/cache@v1
43+
if: ${{ true }}
44+
with:
45+
path: ~/.CommandBox/artifacts
46+
key: ${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }}-${{ hashFiles( 'test-harness/box.json' ) }}
47+
restore-keys: |
48+
${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }}-${{ hashFiles( 'test-harness/box.json' ) }}
49+
4150
- name: Setup CommandBox
4251
uses: Ortus-Solutions/setup-commandbox@main
4352
with:
@@ -55,7 +64,6 @@ jobs:
5564
then
5665
echo "BRANCH=development" >> $GITHUB_ENV
5766
fi
58-
5967
- name: Build ${{ env.MODULE_ID }}
6068
run: |
6169
box install commandbox-docbox
@@ -97,7 +105,7 @@ jobs:
97105
cat box.json
98106
box forgebox publish
99107
100-
- name: Inform Slack
108+
- name: Inform Slack of Build
101109
if: ${{ always() }}
102110
uses: rtCamp/action-slack-notify@v2
103111
env:

.github/workflows/tests.yml

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
workflow_call:
66
secrets:
77
SLACK_WEBHOOK_URL:
8-
required: true
8+
required: false
99

1010
jobs:
1111
tests:
@@ -17,34 +17,45 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
cfengine: [ "lucee@5", "adobe@2016", "adobe@2018", "adobe@2021" ]
20+
cfengine: [ "lucee@5", "adobe@2018", "adobe@2021" ]
2121
steps:
2222
- name: Checkout Repository
2323
uses: actions/checkout@v2
2424

25+
# Not Needed in this module
26+
#- name: Setup Database and Fixtures
27+
# run: |
28+
# sudo /etc/init.d/mysql start
29+
# mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -e 'CREATE DATABASE coolblog;'
30+
# mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < test-harness/tests/resources/coolblog.sql
31+
2532
- name: Setup Java
2633
uses: actions/setup-java@v2
2734
with:
2835
distribution: "adopt"
2936
java-version: "11"
3037

31-
- name: Setup Environment For Testing Process
32-
run: |
33-
# Setup .env
34-
touch .env
35-
# ENV
36-
printf "ENVIRONMENT=development\n" >> .env
37-
printf "DB_HOST=localhost\n" >> .env
38-
printf "DB_USER=${{ env.DB_USER }}\n" >> .env
39-
printf "DB_PASSWORD=${{ env.DB_PASSWORD }}\n" >> .env
40-
printf "DB_CLASS=com.mysql.cj.jdbc.Driver\n" >> .env
41-
printf "DB_BUNDLEVERSION=8.0.19\n" >> .env
42-
printf "DB_BUNDLENAME=com.mysql.cj\n" >> .env
43-
4438
- name: Setup CommandBox CLI
4539
uses: Ortus-Solutions/setup-commandbox@main
4640

47-
- name: Install Dependencies
41+
# Not Needed in this module
42+
#- name: Setup Environment For Testing Process
43+
# working-directory: ./test-harness
44+
# run: |
45+
# # Setup .env
46+
# touch .env
47+
# # ENV
48+
# printf "DB_HOST=localhost\n" >> .env
49+
# printf "DB_DATABASE=mydatabase\n" >> .env
50+
# printf "DB_DRIVER=MySQL\n" >> .env
51+
# printf "DB_USER=${{ env.DB_USER }}\n" >> .env
52+
# printf "DB_PASSWORD=${{ env.DB_PASSWORD }}\n" >> .env
53+
# printf "DB_CLASS=com.mysql.cj.jdbc.Driver\n" >> .env
54+
# printf "DB_BUNDLEVERSION=8.0.19\n" >> .env
55+
# printf "DB_BUNDLENAME=com.mysql.cj\n" >> .env
56+
57+
58+
- name: Install Test Harness Dependencies
4859
run: |
4960
box install
5061
cd test-harness && box install
@@ -62,7 +73,6 @@ jobs:
6273
run: |
6374
mkdir -p test-harness/tests/results
6475
box testbox run --verbose outputFile=test-harness/tests/results/test-results outputFormats=json,antjunit
65-
ls -lR test-harness/tests
6676
6777
- name: Publish Test Results
6878
uses: EnricoMi/publish-unit-test-result-action@v1
@@ -79,12 +89,12 @@ jobs:
7989
path: |
8090
test-harness/tests/results/**/*
8191
82-
- name: Failure Debugging Log
92+
- name: Show Server Log On Failures
8393
if: ${{ failure() }}
8494
run: |
8595
box server log serverConfigFile="server-${{ matrix.cfengine }}.json"
8696
87-
- name: Upload Debugging Log To Artifacts
97+
- name: Upload Debug Logs To Artifacts
8898
if: ${{ failure() }}
8999
uses: actions/upload-artifact@v2
90100
with:

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
"directoryPath": "./test-harness/coldbox",
66
"isPhysicalDirectoryPath": false
77
},
8+
{
9+
"logicalPath": "/testbox",
10+
"directoryPath": "./test-harness/testbox",
11+
"isPhysicalDirectoryPath": false
12+
},
813
{
914
"logicalPath": "/cbvalidation",
1015
"directoryPath": "./",

ModuleConfig.cfc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ component {
3030
function configure(){
3131
// Mixin our own methods on handlers, interceptors and views via the ColdBox UDF Library File setting
3232
settings = {
33+
// The default Validation manager
3334
manager : this.COLDBOX_VALIDATION_MANAGER,
34-
// i18nResource = "",
35+
// Global constraints
3536
sharedConstraints : {}
3637
};
3738
}

box.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name":"ColdBox Validation",
33
"author":"Ortus Solutions <[email protected]>",
4-
"version":"3.4.0",
4+
"version":"4.0.0",
55
"location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbvalidation/@build.version@/[email protected]@.zip",
66
"slug":"cbvalidation",
77
"type":"modules",
@@ -23,9 +23,9 @@
2323
"Curt Gratz <[email protected]>"
2424
],
2525
"dependencies":{
26-
"cbi18n":"^2.0.0"
26+
"cbi18n":"^3.0.0"
2727
},
28-
"devDependencies":{
28+
"devDependencies":{
2929
"commandbox-cfformat":"*",
3030
"commandbox-docbox":"*",
3131
"commandbox-dotenv":"*",
@@ -36,7 +36,7 @@
3636
"test-harness",
3737
"/server*.json"
3838
],
39-
"testbox":{
39+
"testbox":{
4040
"runner":"http://localhost:60299/tests/runner.cfm"
4141
},
4242
"scripts":{
@@ -50,5 +50,8 @@
5050
"cfpm:install":"echo '\".engine/adobe2021/WEB-INF/cfusion/bin/cfpm.sh\" install ${1}' | run",
5151
"install:2021":"run-script cfpm:install zip",
5252
"install:dependencies":"install && cd test-harness && install"
53+
},
54+
"installPaths":{
55+
"cbi18n":"modules/cbi18n/"
5356
}
5457
}

changelog.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
----
99

10-
## [3.4.0] => 2022-JUN-
10+
## [4.0.0] => 2022-OCT-10
11+
12+
### Added
13+
14+
* Major bump of all dependencies
15+
* New `InstanceOf` validator thanks to @homestar9 : https://github.com/coldbox-modules/cbvalidation/pull/65
16+
* New virtual app testing and tuning
17+
18+
### Fixed
19+
20+
* Fix process result metadata replacements https://github.com/coldbox-modules/cbvalidation/pull/64/files thanks to @alessio-de-padova, when using full null support
21+
22+
### Changed
23+
24+
* Dropped ACF2016
25+
26+
----
27+
28+
## [3.4.0] => 2022-JUN-27
1129

1230
### Added
1331

models/ValidationManager.cfc

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ component accessors="true" serialize="false" singleton {
6262
/**
6363
* A resource bundle plugin for i18n capabilities
6464
*/
65-
property name="resourceService" inject="ResourceService@cbi18n";
65+
property name="resourceService" inject="provider:ResourceService@cbi18n";
6666

6767
/**
6868
* Shared constraints that can be loaded into the validation manager
@@ -74,9 +74,6 @@ component accessors="true" serialize="false" singleton {
7474
*/
7575
property name="registeredValidators" type="Struct";
7676

77-
// Unique manager id
78-
this.id = createUUID();
79-
8077
/**
8178
* Constructor
8279
*
@@ -85,10 +82,8 @@ component accessors="true" serialize="false" singleton {
8582
ValidationManager function init( struct sharedConstraints = {} ){
8683
// store shared constraints if passed
8784
variables.sharedConstraints = arguments.sharedConstraints;
88-
// Validators Path
89-
variables.validatorsPath = getDirectoryFromPath( getMetadata( this ).path ) & "validators";
9085
// Register validators
91-
variables.registeredValidators = discoverValidators( variables.validatorsPath );
86+
variables.registeredValidators = "";
9287
// Register aliases
9388
variables.validatorAliases = {
9489
"items" : "arrayItem",
@@ -98,7 +93,26 @@ component accessors="true" serialize="false" singleton {
9893
return this;
9994
}
10095

101-
public struct function discoverValidators( required string path ){
96+
/**
97+
* Lazy loader getter to get all the registered validators in the system
98+
*
99+
* @return The discovered map of validators and aliases
100+
*/
101+
struct function getRegisteredValidators(){
102+
if( isSimpleValue( variables.registeredValidators ) ){
103+
variables.registeredValidators = discoverValidators( getDirectoryFromPath( getMetadata( this ).path ) & "validators" );
104+
}
105+
return variables.registeredValidators;
106+
}
107+
108+
/**
109+
* Discover all the core validators found in the system
110+
*
111+
* @path The path to discover
112+
*
113+
* @return The discovered map of validators and aliases
114+
*/
115+
private struct function discoverValidators( required string path ){
102116
return directoryList( arguments.path, false, "name", "*.cfc" )
103117
// don't do the interfaces
104118
.filter( function( item ){
@@ -316,14 +330,16 @@ component accessors="true" serialize="false" singleton {
316330
* @throws ValidationManager.InvalidValidatorType
317331
*/
318332
any function getValidator( required string validatorType, required any validationData ){
333+
var coreValidators = getRegisteredValidators();
334+
319335
// Are we an alias?
320336
if ( structKeyExists( variables.validatorAliases, arguments.validatorType ) ) {
321337
arguments.validatorType = variables.validatorAliases[ arguments.validatorType ];
322338
}
323339

324340
// Are we a core validator?
325-
if ( structKeyExists( variables.registeredValidators, arguments.validatorType ) ) {
326-
return wirebox.getInstance( variables.registeredValidators[ arguments.validatorType ] );
341+
if ( structKeyExists( coreValidators, arguments.validatorType ) ) {
342+
return wirebox.getInstance( coreValidators[ arguments.validatorType ] );
327343
}
328344

329345
// Else switch checks

models/result/ValidationError.cfc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ component accessors="true" {
88

99
// constructor
1010
ValidationError function init(){
11-
message = "";
12-
field = "";
13-
rejectedValue = "";
14-
validationType = "";
15-
validationData = "";
16-
errorMetadata = {};
11+
variables.message = "";
12+
variables.field = "";
13+
variables.rejectedValue = "";
14+
variables.validationType = "";
15+
variables.validationData = "";
16+
variables.errorMetadata = {};
1717
return this;
1818
}
1919

@@ -33,7 +33,7 @@ component accessors="true" {
3333
* Get the error metadata
3434
*/
3535
struct function getErrorMetadata(){
36-
return variables.errorMetadata;
36+
return variables.errorMetadata ?: {};
3737
}
3838

3939
/**

0 commit comments

Comments
 (0)