Skip to content

Commit a533b41

Browse files
committed
Merge branch 'development'
2 parents 08d7748 + 0595ecd commit a533b41

17 files changed

+610
-396
lines changed

.cfformat.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"brackets.padding": true,
3+
"strings.quote": "double",
4+
"strings.attributes.quote": "double",
5+
"function_call.empty_padding": false,
6+
"function_call.padding": true,
7+
"function_declaration.padding": true,
8+
"function_call.multiline.leading_comma.padding": true,
9+
"function_declaration.multiline.leading_comma.padding" : true,
10+
"function_declaration.empty_padding": false,
11+
"function_declaration.group_to_block_spacing": "compact",
12+
"struct.padding": true,
13+
"struct.empty_padding": false,
14+
"struct.multiline.leading_comma.padding" : true,
15+
"array.empty_padding":false,
16+
"array.padding":true,
17+
"array.multiline.leading_comma.padding":true,
18+
"binary_operators.padding":true,
19+
"for_loop_semicolons.padding":true,
20+
"indent_size":4,
21+
"parentheses.padding":true,
22+
"struct.separator":" : ",
23+
"tab_indent":true,
24+
"keywords.block_to_keyword_spacing" : "spaced",
25+
"keywords.group_to_block_spacing" : "spaced",
26+
"keywords.padding_inside_group" : true,
27+
"keywords.spacing_to_block" : "compact",
28+
"keywords.spacing_to_group" : true
29+
}

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ sudo: required
2626
before_install:
2727
# CommandBox Keys
2828
- curl -fsSl https://downloads.ortussolutions.com/debs/gpg | sudo apt-key add -
29-
- sudo echo "deb http://downloads.ortussolutions.com/debs/noarch /" | sudo tee -a
29+
- sudo echo "deb https://downloads.ortussolutions.com/debs/noarch /" | sudo tee -a
3030
/etc/apt/sources.list.d/commandbox.list
3131

3232
install:
3333
# Install Commandbox
3434
- sudo apt-get update && sudo apt-get --assume-yes install rsync jq commandbox
3535
# Install CommandBox Supporting Librarires
36-
- box install commandbox-cfconfig,commandbox-dotenv,commandbox-docbox
36+
- box install commandbox-cfconfig,commandbox-dotenv,commandbox-docbox,commandbox-cfformat
3737
# If using auto-publish, you will need to provide your API token with this line:
3838
- box config set endpoints.forgebox.APIToken=$FORGEBOX_API_TOKEN > /dev/null
3939

box.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name":"ColdBox Validation",
3-
"author":"Ortus Solutions.com <[email protected]",
4-
"version":"1.4.1",
3+
"author":"Ortus Solutions <[email protected]>",
4+
"version":"1.5.0",
55
"location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbvalidation/@build.version@/[email protected]@.zip",
66
"slug":"cbvalidation",
77
"type":"modules",
88
"homepage":"https://github.com/coldbox-modules/cbvalidation",
9-
"documentation":"https://github.com/coldbox-modules/cbvalidation/wiki",
9+
"documentation":"https://coldbox-validation.ortusbooks.com/",
1010
"repository":{
1111
"type":"git",
1212
"url":"https://github.com/coldbox-modules/cbvalidation"
@@ -23,7 +23,7 @@
2323
"Curt Gratz <[email protected]>"
2424
],
2525
"dependencies":{
26-
"cbi18n":"^1.3.1"
26+
"cbi18n":"^1.4.0"
2727
},
2828
"ignore":[
2929
"**/.*",

build/Build.cfc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ component{
5656
buildID=createUUID(),
5757
branch="development"
5858
){
59+
// Create project mapping
60+
fileSystemUtil.createMapping( arguments.projectName, variables.cwd );
5961

6062
// Run the tests
6163
runTests();
@@ -76,7 +78,7 @@ component{
7678
.toConsole();
7779
}
7880

79-
/**
81+
/**
8082
* Run the test suites
8183
*/
8284
function runTests(){

changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# CHANGELOG
22

3+
## 1.5.0
4+
5+
* `features` : `validateOrFail()` new method to validate and if it fails it will throw a `ValidationException`. Also if the target is an object, the object is returned. If the target is a struct, the struct is returned ONLY with the validated fields.
6+
* `feature` : `validateModel()` is now deprecated in favor of `validate()`. `validateModel()` is now marked for deprecation.
7+
* `improvement` : Direct scoping for performance an avoidance of lookup bugs
8+
* `improvement` : HTTPS protocol for everything
9+
* `improvement` : Updated to testbox 3
10+
* `bug` : Fix mapping declaration for apidocs`
11+
* `bug` : Missing return on `addSharedConstraint()` function
12+
13+
314
## 1.4.1
415

516
* Location protocol

models/GenericObject.cfc

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
/**
2-
********************************************************************************
3-
Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
4-
www.coldbox.org | www.luismajano.com | www.ortussolutions.com
5-
********************************************************************************
6-
A generic object that can simulate an object getters from a collection structure.
7-
Great for when you want to validate a form that is not represented by an object.
8-
*/
2+
* *******************************************************************************
3+
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
4+
* www.ortussolutions.com
5+
* *******************************************************************************
6+
* Great for when you want to validate a form that is not represented by an object.
7+
* A generic object that can simulate an object getters from a collection structure.
8+
*/
99
component{
1010

11-
// constructor
11+
/**
12+
* Constructor
13+
*
14+
* @memento The struct to represent
15+
*/
1216
GenericObject function init( struct memento=structNew() ){
13-
collection = arguments.memento;
17+
variables.collection = arguments.memento;
1418
return this;
1519
}
1620

17-
// Get the object's collection memento
21+
/**
22+
* Retrieve the collection
23+
*/
1824
any function getMemento(){
19-
return collection;
25+
return variables.collection;
2026
}
2127

22-
// Process getters and setters
28+
/**
29+
* Process dynamic getters
30+
*
31+
* @missingMethodName
32+
* @missingMethodArguments
33+
*/
2334
any function onMissingMethod( required string missingMethodName, required struct missingMethodArguments ){
24-
var key = replacenocase( arguments.missingMethodName, "get","");
35+
var key = replacenocase( arguments.missingMethodName, "get", "" );
2536

26-
if( structKeyExists( collection, key ) ){
27-
return collection[ key ];
37+
if( structKeyExists( variables.collection, key ) ){
38+
return variables.collection[ key ];
2839
}
2940

3041
// Return null

models/IValidationManager.cfc

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,61 @@
11
/**
2-
********************************************************************************
3-
Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
4-
www.coldbox.org | www.luismajano.com | www.ortussolutions.com
5-
********************************************************************************
6-
The ColdBox validation manager interface, all inspired by awesome Hyrule Validation Framework by Dan Vega
7-
*/
2+
* *******************************************************************************
3+
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
4+
* www.ortussolutions.com
5+
* *******************************************************************************
6+
* The ColdBox validation manager interface, all inspired by awesome Hyrule Validation Framework by Dan Vega
7+
*/
88
import cbvalidation.models.*;
99
import cbvalidation.models.result.*;
1010
interface{
1111

1212
/**
13-
* Validate an object
14-
* @targetThe target object to validate
15-
* @fieldsOne or more fields to validate on, by default it validates all fields in the constraints. This can be a simple list or an array.
16-
* @constraintsAn optional shared constraints name or an actual structure of constraints to validate on.
17-
* @localeAn optional locale to use for i18n messages
18-
* @excludeFieldsAn optional list of fields to exclude from the validation.
19-
* @includeFieldsAn optional list of fields to include in the validation.
20-
*/
21-
IValidationResult function validate( required any target, string fields, any constraints, string locale="", string excludeFields="", string includeFields="" );
13+
* Validate an object
14+
*
15+
* @targetThe target object to validate
16+
* @fieldsOne or more fields to validate on, by default it validates all fields in the constraints. This can be a simple list or an array.
17+
* @constraintsAn optional shared constraints name or an actual structure of constraints to validate on.
18+
* @localeAn optional locale to use for i18n messages
19+
* @excludeFieldsAn optional list of fields to exclude from the validation.
20+
* @includeFieldsAn optional list of fields to include in the validation.
21+
*
22+
* @result ValidationResult object
23+
*/
24+
IValidationResult function validate(
25+
required any target,
26+
string fields,
27+
any constraints,
28+
string locale="",
29+
string excludeFields="",
30+
string includeFields=""
31+
);
2232

2333
/**
24-
* Retrieve the shared constraints
25-
* @nameFilter by name or not
26-
*/
34+
* Retrieve the shared constraints
35+
*
36+
* @nameFilter by name or not
37+
*/
2738
struct function getSharedConstraints( string name );
2839

2940
/**
30-
* Check if a shared constraint exists by name
31-
* @nameThe shared constraint to check
32-
*/
41+
* Check if a shared constraint exists by name
42+
*
43+
* @nameThe shared constraint to check
44+
*/
3345
boolean function sharedConstraintsExists( required string name );
3446

3547
/**
36-
* Set the shared constraints into the validation manager, usually these are described in the ColdBox configuraiton file
37-
* @constraintsFilter by name or not
38-
*/
48+
* Set the shared constraints into the validation manager, usually these are described in the ColdBox configuraiton file
49+
*
50+
* @constraintsFilter by name or not
51+
*/
3952
IValidationManager function setSharedConstraints( struct constraints );
4053

4154
/**
42-
* Store a shared constraint
43-
* @nameFilter by name or not
44-
* @constraintThe constraint to store.
45-
*/
55+
* Store a shared constraint
56+
*
57+
* @nameFilter by name or not
58+
* @constraintThe constraint to store.
59+
*/
4660
IValidationManager function addSharedConstraint( required string name, required struct constraint );
4761
}

models/Mixins.cfm

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,51 @@
11
<cfscript>
22
33
/**
4-
* Validate an object or structure according to the constraints rules.
5-
* @target An object or structure to validate
6-
* @fields The fields to validate on the target. By default, it validates on all fields
7-
* @constraints A structure of constraint rules or the name of the shared constraint rules to use for validation
8-
* @locale The i18n locale to use for validation messages
9-
* @excludeFields The fields to exclude from the validation
10-
* @includeFields The fields to include in the validation
11-
*
12-
* @return cbvalidation.model.result.IValidationResult
13-
*/
4+
* Validate an object or structure according to the constraints rules.
5+
*
6+
* @target An object or structure to validate
7+
* @fields The fields to validate on the target. By default, it validates on all fields
8+
* @constraints A structure of constraint rules or the name of the shared constraint rules to use for validation
9+
* @locale The i18n locale to use for validation messages
10+
* @excludeFields The fields to exclude from the validation
11+
* @includeFields The fields to include in the validation
12+
*
13+
* @return cbvalidation.model.result.IValidationResult
14+
*/
15+
function validate(){
16+
return getValidationManager().validate( argumentCollection=arguments );
17+
}
18+
19+
/**
20+
* Validate an object or structure according to the constraints rules and throw an exception if the validation fails.
21+
* The validation errors will be contained in the `extendedInfo` of the exception in JSON format
22+
*
23+
* @target An object or structure to validate
24+
* @fields The fields to validate on the target. By default, it validates on all fields
25+
* @constraints A structure of constraint rules or the name of the shared constraint rules to use for validation
26+
* @locale The i18n locale to use for validation messages
27+
* @excludeFields The fields to exclude from the validation
28+
* @includeFields The fields to include in the validation
29+
*
30+
* @return The validated object or the structure fields that where validated
31+
* @throws ValidationException
32+
*/
33+
function validateOrFail(){
34+
return getValidationManager().validateOrFail( argumentCollection=arguments );
35+
}
36+
37+
/**
38+
* Retrieve the application's configured Validation Manager
39+
*/
40+
function getValidationManager(){
41+
return wirebox.getInstance( "ValidationManager@cbvalidation" );
42+
}
43+
44+
/**
45+
* @deprecated
46+
*
47+
* Marked for deprecation, use `validate()` instead
48+
*/
1449
function validateModel(
1550
required any target,
1651
string fields="*",
@@ -19,14 +54,7 @@ function validateModel(
1954
string excludeFields="",
2055
string includeFields=""
2156
){
22-
return getValidationManager().validate( argumentCollection=arguments );
57+
return this.validate( argumentCollection=arguments );
2358
}
2459
25-
/**
26-
* Retrieve the application's configured Validation Manager
27-
*/
28-
function getValidationManager(){
29-
return wirebox.getInstance( "ValidationManager@cbvalidation" );
30-
}
31-
3260
</cfscript>

0 commit comments

Comments
 (0)