Commit 39c4e39d authored by Nigel Kukard's avatar Nigel Kukard

Merge branch 'nkwork3' into 'master'

Nkwork3

See merge request !22
parents 47322017 8982f23b
Pipeline #1912 passed with stages
in 1 minute and 24 seconds
...@@ -161,18 +161,17 @@ The C<new> method is used to instantiate the object. ...@@ -161,18 +161,17 @@ The C<new> method is used to instantiate the object.
Data object C<options> can also be specified to customize the objects behavior. Data object C<options> can also be specified to customize the objects behavior.
=head3 Options =head3 B<$options>
Each object supports options being passed as a parameter to C<new> described below... Each object supports options being passed as a parameter to C<new> described below...
'options' => OPTION1 | OPTION2 'options' => OBJ_OPTION1 | OBJ_OPTION2
Below is a list of supported options: Below is a list of supported object options:
=over =over
=item * =item B<DATAOBJ_LOADONIDSET>
B<DATAOBJ_LOADONIDSET>
This property will cause the object to load when a DATAOBJ_PROPERTY_ID is set. This property will cause the object to load when a DATAOBJ_PROPERTY_ID is set.
...@@ -193,9 +192,11 @@ This property will cause the object to load when a DATAOBJ_PROPERTY_ID is set. ...@@ -193,9 +192,11 @@ This property will cause the object to load when a DATAOBJ_PROPERTY_ID is set.
retrun { retrun {
'properties' => { 'properties' => {
'OwnerID' => { }, # No parameters as its pretty much handled by the relation 'OwnerID' => { }, # No parameters as its pretty much handled by the relation
'Description' => { 'SomePropertyName' => {
'description' => "Description of the item",
'validate' => { 'type' => 'text', 'length' => 2 }, 'validate' => { 'type' => 'text', 'length' => 2 },
# 'options' => ... property options can be specified here # 'options' => ... property options can be specified here
'example' => "some example value",
} }
}, },
'relations' => { 'relations' => {
...@@ -212,7 +213,17 @@ This property will cause the object to load when a DATAOBJ_PROPERTY_ID is set. ...@@ -212,7 +213,17 @@ This property will cause the object to load when a DATAOBJ_PROPERTY_ID is set.
The C<config> method is used to return configuration information for the current object, it must be overridden for each object The C<config> method is used to return configuration information for the current object, it must be overridden for each object
created and must return a hashref with the object configuration. created and must return a hashref with the object configuration.
=head3 Property Options =head3 B<Property Configuration>
Each property supports a number of options described below...
'description' => "Description of property"
'options' => OPTION1 | OPTION2
'validate' => { 'type' => <VALIDATE_TYPE>, <VALIDATION_OPTIONS>... }
'example' => "some example value"
=head3 B<Property Options>
Each property supports options described below... Each property supports options described below...
...@@ -222,35 +233,30 @@ Below is a list of supported options: ...@@ -222,35 +233,30 @@ Below is a list of supported options:
=over =over
=item * =item B<DATAOBJ_PROPERTY_ID>
B<DATAOBJ_PROPERTY_ID>
This is the unique ID property of the object, only ONE of these can be specified! This is the unique ID property of the object, only ONE of these can be specified!
=item * =item B<DATAOBJ_PROPERTY_NOLOAD>
B<DATAOBJ_PROPERTY_NOLOAD>
This property will not be loaded. This property will not be loaded.
=item * =item B<DATAOBJ_PROPERTY_NOSAVE>
B<DATAOBJ_PROPERTY_NOSAVE>
This property is not saved. This property is not saved.
=item * =item B<DATAOBJ_PROPERTY_READONLY>
B<DATAOBJ_PROPERTY_READONLY>
Ensure this property cannot be set using ->setXXX(). Ensure this property cannot be set using ->setXXX().
=item * =item B<DATAOBJ_PROPERTY_REQUIRED>
B<DATAOBJ_PROPERTY_REQUIRED>
This property must be set before using ->commit(). This property must be set before using ->commit().
=back =back
=head3 Property Validation =head3 B<Property Validation>
Each property supports optional validation criteria described below... Each property supports optional validation criteria described below...
...@@ -260,86 +266,73 @@ Below is a list of supported validation types: ...@@ -260,86 +266,73 @@ Below is a list of supported validation types:
=over =over
=item * =item B<text>
B<text>
Validate text. The C<length> and C<regex> options are supported. Validate text. The C<length> and C<regex> options are supported.
=over =over
=item * =item B<length>
B<length>
Optional minimum length. Optional minimum length.
=item * =item B<regex>
B<regex>
Optional regex, eg. qr ( /^ABc/ ). Optional regex, eg. qr ( /^ABc/ ).
=back =back
=item * =item B<username>
B<username>
Validate username, additional parameters in C<params> can be passed for validation. Validate username, additional parameters in C<params> can be passed for validation.
=over =over
=item * =item B<params> (arrayref)
B<params> (arrayref)
See L<AWITPT::Util> for options for C<isUsername>. See L<AWITPT::Util> for options for C<isUsername>.
=back =back
=item * =item B<email>
B<email>
Validate an email address. Validate an email address.
=item * =item B<boolean>
B<boolean>
Validate boolean. Validate boolean.
=item * =item B<domain>
B<domain>
Validate domain. Validate domain.
=item * =item B<number>
B<number>
Validate number, additional validation options can be specified using the C<params> option. Validate number, additional validation options can be specified using the C<params> option.
=over =over
=item * =item B<params> (arrayref)
B<params> (arrayref)
See L<AWITPT::Util> for options for C<isNumber>. See L<AWITPT::Util> for options for C<isNumber>.
=back =back
=item * =item B<regex>
B<regex>
Validate against a regex. The C<regex> option must be specified with a qr(/..../) regex. Validate against a regex. The C<regex> option must be specified with a qr(/..../) regex.
=item * =item B<relation>
B<relation>
Validate using the related object. This calls the related objects validate() method. Validate using the related object. This calls the related objects validate() method.
=item * =item B<load>
B<load>
Validate by attempting to load the property, this calls the load() method on the current object. Validate by attempting to load the property, this calls the load() method on the current object.
=back =back
=head3 Relation Options =head3 B<Relation Options>
Each relation defined supports a number of options described below... Each relation defined supports a number of options described below...
...@@ -349,8 +342,7 @@ Below is a list of supported options: ...@@ -349,8 +342,7 @@ Below is a list of supported options:
=over =over
=item * =item B<DATAOBJ_RELATION_READONLY>
B<DATAOBJ_RELATION_READONLY>
The child object will not be created if it does not exist. This only pertains to the 'Direct' relation. The child object will not be created if it does not exist. This only pertains to the 'Direct' relation.
...@@ -1389,6 +1381,9 @@ sub _init ...@@ -1389,6 +1381,9 @@ sub _init
# Reset our internal list of properties, used for cloning # Reset our internal list of properties, used for cloning
$self->{'_internal_properties'} = {}; $self->{'_internal_properties'} = {};
# Save a copy of our config
$self->{'_config'} = $config;
# If we still have params, load them # If we still have params, load them
if (@params) { if (@params) {
$self->loadHash(@params); $self->loadHash(@params);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment