Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
lmajano committed Oct 10, 2022
2 parents 75cccaf + f08a83e commit 93ce81e
Show file tree
Hide file tree
Showing 24 changed files with 319 additions and 150 deletions.
5 changes: 3 additions & 2 deletions .cfconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"adminPassword" : "coldbox",
"debuggingEnabled":true,
"debuggingReportExecutionTimes":false,
"disableInternalCFJavaComponents":false,
"inspectTemplate":"always",
"requestTimeout":"0,0,0,90",
"robustExceptionEnabled":true
}
"robustExceptionEnabled":true,
}
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
MODULE_ID: cbvalidation

jobs:
#############################################
#############################################
# Tests First baby! We fail, no build :(
#############################################
tests:
Expand All @@ -20,7 +20,7 @@ jobs:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

#############################################
# Build Module
# Build
#############################################
build:
name: Build & Publish
Expand All @@ -38,6 +38,15 @@ jobs:
distribution: "adopt"
java-version: "11"

- name: Cache CommandBox Dependencies
uses: actions/cache@v1
if: ${{ true }}
with:
path: ~/.CommandBox/artifacts
key: ${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }}-${{ hashFiles( 'test-harness/box.json' ) }}
restore-keys: |
${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }}-${{ hashFiles( 'test-harness/box.json' ) }}
- name: Setup CommandBox
uses: Ortus-Solutions/setup-commandbox@main
with:
Expand All @@ -55,7 +64,6 @@ jobs:
then
echo "BRANCH=development" >> $GITHUB_ENV
fi
- name: Build ${{ env.MODULE_ID }}
run: |
box install commandbox-docbox
Expand Down Expand Up @@ -97,7 +105,7 @@ jobs:
cat box.json
box forgebox publish
- name: Inform Slack
- name: Inform Slack of Build
if: ${{ always() }}
uses: rtCamp/action-slack-notify@v2
env:
Expand Down
48 changes: 29 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_call:
secrets:
SLACK_WEBHOOK_URL:
required: true
required: false

jobs:
tests:
Expand All @@ -17,34 +17,45 @@ jobs:
strategy:
fail-fast: false
matrix:
cfengine: [ "lucee@5", "adobe@2016", "adobe@2018", "adobe@2021" ]
cfengine: [ "lucee@5", "adobe@2018", "adobe@2021" ]
steps:
- name: Checkout Repository
uses: actions/checkout@v2

# Not Needed in this module
#- name: Setup Database and Fixtures
# run: |
# sudo /etc/init.d/mysql start
# mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -e 'CREATE DATABASE coolblog;'
# mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < test-harness/tests/resources/coolblog.sql

- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: "11"

- name: Setup Environment For Testing Process
run: |
# Setup .env
touch .env
# ENV
printf "ENVIRONMENT=development\n" >> .env
printf "DB_HOST=localhost\n" >> .env
printf "DB_USER=${{ env.DB_USER }}\n" >> .env
printf "DB_PASSWORD=${{ env.DB_PASSWORD }}\n" >> .env
printf "DB_CLASS=com.mysql.cj.jdbc.Driver\n" >> .env
printf "DB_BUNDLEVERSION=8.0.19\n" >> .env
printf "DB_BUNDLENAME=com.mysql.cj\n" >> .env
- name: Setup CommandBox CLI
uses: Ortus-Solutions/setup-commandbox@main

- name: Install Dependencies
# Not Needed in this module
#- name: Setup Environment For Testing Process
# working-directory: ./test-harness
# run: |
# # Setup .env
# touch .env
# # ENV
# printf "DB_HOST=localhost\n" >> .env
# printf "DB_DATABASE=mydatabase\n" >> .env
# printf "DB_DRIVER=MySQL\n" >> .env
# printf "DB_USER=${{ env.DB_USER }}\n" >> .env
# printf "DB_PASSWORD=${{ env.DB_PASSWORD }}\n" >> .env
# printf "DB_CLASS=com.mysql.cj.jdbc.Driver\n" >> .env
# printf "DB_BUNDLEVERSION=8.0.19\n" >> .env
# printf "DB_BUNDLENAME=com.mysql.cj\n" >> .env


- name: Install Test Harness Dependencies
run: |
box install
cd test-harness && box install
Expand All @@ -62,7 +73,6 @@ jobs:
run: |
mkdir -p test-harness/tests/results
box testbox run --verbose outputFile=test-harness/tests/results/test-results outputFormats=json,antjunit
ls -lR test-harness/tests
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
Expand All @@ -79,12 +89,12 @@ jobs:
path: |
test-harness/tests/results/**/*
- name: Failure Debugging Log
- name: Show Server Log On Failures
if: ${{ failure() }}
run: |
box server log serverConfigFile="server-${{ matrix.cfengine }}.json"
- name: Upload Debugging Log To Artifacts
- name: Upload Debug Logs To Artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"directoryPath": "./test-harness/coldbox",
"isPhysicalDirectoryPath": false
},
{
"logicalPath": "/testbox",
"directoryPath": "./test-harness/testbox",
"isPhysicalDirectoryPath": false
},
{
"logicalPath": "/cbvalidation",
"directoryPath": "./",
Expand Down
3 changes: 2 additions & 1 deletion ModuleConfig.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ component {
function configure(){
// Mixin our own methods on handlers, interceptors and views via the ColdBox UDF Library File setting
settings = {
// The default Validation manager
manager : this.COLDBOX_VALIDATION_MANAGER,
// i18nResource = "",
// Global constraints
sharedConstraints : {}
};
}
Expand Down
11 changes: 7 additions & 4 deletions box.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name":"ColdBox Validation",
"author":"Ortus Solutions <[email protected]>",
"version":"3.4.0",
"version":"4.0.0",
"location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbvalidation/@build.version@/[email protected]@.zip",
"slug":"cbvalidation",
"type":"modules",
Expand All @@ -23,9 +23,9 @@
"Curt Gratz <[email protected]>"
],
"dependencies":{
"cbi18n":"^2.0.0"
"cbi18n":"^3.0.0"
},
"devDependencies":{
"devDependencies":{
"commandbox-cfformat":"*",
"commandbox-docbox":"*",
"commandbox-dotenv":"*",
Expand All @@ -36,7 +36,7 @@
"test-harness",
"/server*.json"
],
"testbox":{
"testbox":{
"runner":"http://localhost:60299/tests/runner.cfm"
},
"scripts":{
Expand All @@ -50,5 +50,8 @@
"cfpm:install":"echo '\".engine/adobe2021/WEB-INF/cfusion/bin/cfpm.sh\" install ${1}' | run",
"install:2021":"run-script cfpm:install zip",
"install:dependencies":"install && cd test-harness && install"
},
"installPaths":{
"cbi18n":"modules/cbi18n/"
}
}
20 changes: 19 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

----

## [3.4.0] => 2022-JUN-
## [4.0.0] => 2022-OCT-10

### Added

* Major bump of all dependencies
* New `InstanceOf` validator thanks to @homestar9 : https://github.com/coldbox-modules/cbvalidation/pull/65
* New virtual app testing and tuning

### Fixed

* Fix process result metadata replacements https://github.com/coldbox-modules/cbvalidation/pull/64/files thanks to @alessio-de-padova, when using full null support

### Changed

* Dropped ACF2016

----

## [3.4.0] => 2022-JUN-27

### Added

Expand Down
36 changes: 26 additions & 10 deletions models/ValidationManager.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ component accessors="true" serialize="false" singleton {
/**
* A resource bundle plugin for i18n capabilities
*/
property name="resourceService" inject="ResourceService@cbi18n";
property name="resourceService" inject="provider:ResourceService@cbi18n";

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

// Unique manager id
this.id = createUUID();

/**
* Constructor
*
Expand All @@ -85,10 +82,8 @@ component accessors="true" serialize="false" singleton {
ValidationManager function init( struct sharedConstraints = {} ){
// store shared constraints if passed
variables.sharedConstraints = arguments.sharedConstraints;
// Validators Path
variables.validatorsPath = getDirectoryFromPath( getMetadata( this ).path ) & "validators";
// Register validators
variables.registeredValidators = discoverValidators( variables.validatorsPath );
variables.registeredValidators = "";
// Register aliases
variables.validatorAliases = {
"items" : "arrayItem",
Expand All @@ -98,7 +93,26 @@ component accessors="true" serialize="false" singleton {
return this;
}

public struct function discoverValidators( required string path ){
/**
* Lazy loader getter to get all the registered validators in the system
*
* @return The discovered map of validators and aliases
*/
struct function getRegisteredValidators(){
if( isSimpleValue( variables.registeredValidators ) ){
variables.registeredValidators = discoverValidators( getDirectoryFromPath( getMetadata( this ).path ) & "validators" );
}
return variables.registeredValidators;
}

/**
* Discover all the core validators found in the system
*
* @path The path to discover
*
* @return The discovered map of validators and aliases
*/
private struct function discoverValidators( required string path ){
return directoryList( arguments.path, false, "name", "*.cfc" )
// don't do the interfaces
.filter( function( item ){
Expand Down Expand Up @@ -316,14 +330,16 @@ component accessors="true" serialize="false" singleton {
* @throws ValidationManager.InvalidValidatorType
*/
any function getValidator( required string validatorType, required any validationData ){
var coreValidators = getRegisteredValidators();

// Are we an alias?
if ( structKeyExists( variables.validatorAliases, arguments.validatorType ) ) {
arguments.validatorType = variables.validatorAliases[ arguments.validatorType ];
}

// Are we a core validator?
if ( structKeyExists( variables.registeredValidators, arguments.validatorType ) ) {
return wirebox.getInstance( variables.registeredValidators[ arguments.validatorType ] );
if ( structKeyExists( coreValidators, arguments.validatorType ) ) {
return wirebox.getInstance( coreValidators[ arguments.validatorType ] );
}

// Else switch checks
Expand Down
14 changes: 7 additions & 7 deletions models/result/ValidationError.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ component accessors="true" {

// constructor
ValidationError function init(){
message = "";
field = "";
rejectedValue = "";
validationType = "";
validationData = "";
errorMetadata = {};
variables.message = "";
variables.field = "";
variables.rejectedValue = "";
variables.validationType = "";
variables.validationData = "";
variables.errorMetadata = {};
return this;
}

Expand All @@ -33,7 +33,7 @@ component accessors="true" {
* Get the error metadata
*/
struct function getErrorMetadata(){
return variables.errorMetadata;
return variables.errorMetadata ?: {};
}

/**
Expand Down
Loading

0 comments on commit 93ce81e

Please sign in to comment.