Skip to content

Commit e3481c6

Browse files
committed
Merge branch 'development'
2 parents 769f028 + c18bed6 commit e3481c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2618
-1267
lines changed

.cfformat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"function_call.padding": true,
1717
"function_call.multiline.leading_comma.padding": true,
1818
"function_call.casing.builtin": "cfdocs",
19-
"function_call.casing.userdefined": "",
19+
"function_call.casing.userdefined": "camel",
2020
"function_call.multiline.element_count": 4,
2121
"function_call.multiline.leading_comma": false,
2222
"function_call.multiline.min_length": 40,

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ env:
1010
- MODULE_ID=cbvalidation
1111
matrix:
1212
- ENGINE=lucee@5
13-
- ENGINE=adobe@11
1413
- ENGINE=adobe@2016
1514
- ENGINE=adobe@2018
1615

box.json

Lines changed: 5 additions & 2 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":"1.5.2",
4+
"version":"2.0.0",
55
"location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbvalidation/@build.version@/[email protected]@.zip",
66
"slug":"cbvalidation",
77
"type":"modules",
@@ -31,6 +31,9 @@
3131
".git*"
3232
],
3333
"scripts":{
34-
"toMaster":"recipe build/toMaster.boxr"
34+
"toMaster":"recipe build/toMaster.boxr",
35+
"format":"cfformat run models/**/*.cfc,ModuleConfig.cfc,tests/specs/**/*.cfc,*.cfc --overwrite",
36+
"format:check":"cfformat run models/**/*.cfc,ModuleConfig.cfc,tests/specs/**/*.cfc,*.cfc --check",
37+
"lint":"cflint models/**.cfc --text --html --json --!exitOnError --suppress"
3538
}
3639
}

changelog.md

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

3+
## 2.0.0
4+
5+
### Features
6+
7+
* No more manual discovery of validators, automated registration and lookup process, cleaned lots of code on this one!
8+
* New Validator: `Accepted` - The field under validation must be yes, on, 1, or true. This is useful for validating "Terms of Service" acceptance.
9+
* New Validator: `Alpha` - Only allows alphabetic characters
10+
* New Validator: `RequiredUnless` with validation data: `anotherField:value,...` - The field under validation must be present and not empty unless the `anotherfield` field is equal to the passed `value`.
11+
* New Validator: `RequiredIf` with validation data: `anotherField:value,...` - The field under validation must be present and not empty if the `anotherfield` field is equal to the passed `value`.
12+
* Accelerated validation by removing type checks. ACF chokes on interface checks
13+
14+
### Improvements
15+
16+
* Consistency on all validators to ignore null or empty values except the `Required` validator
17+
* Formatting consistencies
18+
* Improve error messages to describe better validation
19+
* Get away from `evaluate()` instead use `invoke()`
20+
21+
### Compat & Bugs
22+
23+
* `Bugs` : Fixed lots of wrong type exceptions
24+
* `Compat` : Remove ACF11 support
25+
26+
`requiredUnless=role,test
27+
---
28+
329
## 1.5.2
430

531
* `bug` : Added `float` to the type validator which was missing

models/GenericObject.cfc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
/**
2-
* *******************************************************************************
3-
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
2+
* Copyright since 2020 by Ortus Solutions, Corp
43
* www.ortussolutions.com
5-
* *******************************************************************************
4+
* ---
65
* Great for when you want to validate a form that is not represented by an object.
76
* A generic object that can simulate an object getters from a collection structure.
87
*/
9-
component{
8+
component {
109

1110
/**
1211
* Constructor
1312
*
1413
* @memento The struct to represent
1514
*/
16-
GenericObject function init( struct memento=structNew() ){
15+
GenericObject function init( struct memento = structNew() ){
1716
variables.collection = arguments.memento;
1817
return this;
1918
}
@@ -32,12 +31,13 @@ component{
3231
* @missingMethodArguments
3332
*/
3433
any function onMissingMethod( required string missingMethodName, required struct missingMethodArguments ){
35-
var key = replacenocase( arguments.missingMethodName, "get", "" );
34+
var key = replaceNoCase( arguments.missingMethodName, "get", "" );
3635

37-
if( structKeyExists( variables.collection, key ) ){
36+
if ( structKeyExists( variables.collection, key ) ) {
3837
return variables.collection[ key ];
3938
}
4039

4140
// Return null
4241
}
43-
}
42+
43+
}

models/IValidationManager.cfc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
/**
2-
* *******************************************************************************
3-
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
2+
* Copyright since 2020 by Ortus Solutions, Corp
43
* www.ortussolutions.com
5-
* *******************************************************************************
4+
* ---
65
* The ColdBox validation manager interface, all inspired by awesome Hyrule Validation Framework by Dan Vega
76
*/
87
import cbvalidation.models.*;
98
import cbvalidation.models.result.*;
10-
interface{
9+
interface {
1110

1211
/**
1312
* Validate an object
@@ -19,15 +18,15 @@ interface{
1918
* @excludeFieldsAn optional list of fields to exclude from the validation.
2019
* @includeFieldsAn optional list of fields to include in the validation.
2120
*
22-
* @result ValidationResult object
21+
* @return IValidationResult
2322
*/
24-
IValidationResult function validate(
23+
any function validate(
2524
required any target,
2625
string fields,
2726
any constraints,
28-
string locale="",
29-
string excludeFields="",
30-
string includeFields=""
27+
string locale = "",
28+
string excludeFields = "",
29+
string includeFields = ""
3130
);
3231

3332
/**
@@ -48,14 +47,19 @@ interface{
4847
* Set the shared constraints into the validation manager, usually these are described in the ColdBox configuraiton file
4948
*
5049
* @constraintsFilter by name or not
50+
*
51+
* @return IValidationManager
5152
*/
52-
IValidationManager function setSharedConstraints( struct constraints );
53+
any function setSharedConstraints( struct constraints );
5354

5455
/**
5556
* Store a shared constraint
5657
*
5758
* @nameFilter by name or not
5859
* @constraintThe constraint to store.
60+
*
61+
* @return IValidationManager
5962
*/
60-
IValidationManager function addSharedConstraint( required string name, required struct constraint );
61-
}
63+
any function addSharedConstraint( required string name, required struct constraint );
64+
65+
}

0 commit comments

Comments
 (0)