| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Concierge::Users::Meta v0.8.0; |
|
2
|
8
|
|
|
8
|
|
5983
|
use v5.36; |
|
|
8
|
|
|
|
|
30
|
|
|
3
|
8
|
|
|
8
|
|
42
|
use Carp qw/ croak carp /; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
475
|
|
|
4
|
8
|
|
|
8
|
|
4686
|
use YAML::Tiny; |
|
|
8
|
|
|
|
|
61209
|
|
|
|
8
|
|
|
|
|
51402
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Metadata for fields in Concierge::Users |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub user_core_fields { |
|
9
|
0
|
|
|
0
|
1
|
0
|
return @Concierge::Users::Meta::core_fields; |
|
10
|
|
|
|
|
|
|
} |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub user_standard_fields { |
|
13
|
0
|
|
|
0
|
1
|
0
|
return @Concierge::Users::Meta::standard_fields; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub user_system_fields { |
|
17
|
0
|
|
|
0
|
1
|
0
|
return @Concierge::Users::Meta::system_fields; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Get field definition for a specific field |
|
21
|
|
|
|
|
|
|
# Returns complete hashref with all field attributes (type, default, validation, etc.) |
|
22
|
|
|
|
|
|
|
# Returns undef if field definition not found in this instance's schema |
|
23
|
|
|
|
|
|
|
sub get_field_definition { |
|
24
|
353
|
|
|
353
|
1
|
6302
|
my ($self, $field) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Only look in instance field_definitions (set during setup) |
|
27
|
|
|
|
|
|
|
# Do NOT fall back to master list - schema should be enforced |
|
28
|
353
|
50
|
|
|
|
1259
|
if ($self->{field_definitions}) { |
|
29
|
353
|
|
|
|
|
1170
|
return $self->{field_definitions}{$field}; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# No field_definitions available (shouldn't happen in normal use) |
|
33
|
0
|
|
|
|
|
0
|
return; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# May be directly called as Concierge::Users::Meta::init_field_meta |
|
38
|
|
|
|
|
|
|
# or Concierge::Users::Meta->init_field_meta |
|
39
|
|
|
|
|
|
|
# Users.pm calls it with its config, which includes any |
|
40
|
|
|
|
|
|
|
# field definitions from the calling app, including |
|
41
|
|
|
|
|
|
|
# overrides of attributes of the standard field definitions |
|
42
|
|
|
|
|
|
|
# Returns the whole backend config, which includes the field definitions |
|
43
|
|
|
|
|
|
|
# as well as the ordered field list. |
|
44
|
|
|
|
|
|
|
sub init_field_meta { |
|
45
|
71
|
|
|
71
|
1
|
254063
|
my ($self, $config) = @_; |
|
46
|
71
|
50
|
|
|
|
418
|
$config = ref $self eq __PACKAGE__ ? $config : $self; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Get field lists from package arrays |
|
49
|
71
|
|
|
|
|
470
|
my @core_fields = @Concierge::Users::Meta::core_fields; |
|
50
|
71
|
|
|
|
|
592
|
my @standard_fields = @Concierge::Users::Meta::standard_fields; |
|
51
|
71
|
|
|
|
|
244
|
my @system_fields = @Concierge::Users::Meta::system_fields; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Assemble backend user data fields; always include core fields |
|
54
|
71
|
|
|
|
|
242
|
my @fields = @core_fields; |
|
55
|
|
|
|
|
|
|
# Start with built-in field definitions (clone to avoid modifying master hash) |
|
56
|
|
|
|
|
|
|
my %merged_definitions = map { |
|
57
|
71
|
|
|
|
|
213
|
$_ => { $Concierge::Users::Meta::field_definitions{$_}->%* } |
|
|
426
|
|
|
|
|
4762
|
|
|
58
|
|
|
|
|
|
|
} @core_fields, @system_fields; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Add requested standard fields |
|
61
|
71
|
|
|
|
|
251
|
my @included_std_fields; |
|
62
|
|
|
|
|
|
|
my @requested_fields; |
|
63
|
71
|
100
|
100
|
|
|
1009
|
if ( !$config->{include_standard_fields} or $config->{include_standard_fields} =~ /^all$/i ) { |
|
64
|
16
|
|
|
|
|
79
|
@included_std_fields = @standard_fields; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
else { |
|
67
|
55
|
50
|
|
|
|
274
|
if ( ref $config->{include_standard_fields} eq 'ARRAY' ) { |
|
|
|
0
|
|
|
|
|
|
|
68
|
55
|
|
|
|
|
199
|
@requested_fields = map { lc $_ } $config->{include_standard_fields}->@*; |
|
|
130
|
|
|
|
|
368
|
|
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
elsif ( ! ref $config->{include_standard_fields} ) { |
|
71
|
0
|
|
|
|
|
0
|
@requested_fields = map { lc $_ } split /\s*[,;]\s*/ => $config->{include_standard_fields}; |
|
|
0
|
|
|
|
|
0
|
|
|
72
|
|
|
|
|
|
|
} |
|
73
|
55
|
|
|
|
|
134
|
my %standard_fields = map { $_ => 1 } @standard_fields; |
|
|
660
|
|
|
|
|
1476
|
|
|
74
|
55
|
|
|
|
|
220
|
for my $fld (@requested_fields) { |
|
75
|
130
|
50
|
|
|
|
332
|
if ($standard_fields{$fld}) { |
|
76
|
130
|
|
|
|
|
370
|
push @included_std_fields => $fld; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
else { |
|
79
|
0
|
|
|
|
|
0
|
carp "Non-standard field requested: $fld; configure with 'app_fields => [ ...]'"; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
71
|
|
|
|
|
237
|
push @fields, @included_std_fields; |
|
84
|
71
|
|
|
|
|
176
|
for my $fld (@included_std_fields) { |
|
85
|
|
|
|
|
|
|
$merged_definitions{$fld} = { $Concierge::Users::Meta::field_definitions{$fld}->%* } |
|
86
|
322
|
50
|
|
|
|
3154
|
if $Concierge::Users::Meta::field_definitions{$fld}; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Process field_overrides - modify built-in field definitions |
|
90
|
|
|
|
|
|
|
# Protected fields (cannot be overridden): user_id, created_date, last_mod_date |
|
91
|
|
|
|
|
|
|
# Protected attributes (cannot be changed): field_name, category |
|
92
|
71
|
100
|
|
|
|
356
|
if ($config->{field_overrides}) { |
|
93
|
|
|
|
|
|
|
# my @protected_fields = qw/ user_id created_date last_mod_date /; |
|
94
|
|
|
|
|
|
|
# my %protected_fields = map { $_ => 1 } @protected_fields; |
|
95
|
|
|
|
|
|
|
# my @protected_attrs = qw/ field_name category /; |
|
96
|
|
|
|
|
|
|
# my %protected_attrs = map { $_ => 1 } @protected_attrs; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my @overrides = ref $config->{field_overrides} eq 'ARRAY' |
|
99
|
|
|
|
|
|
|
? $config->{field_overrides}->@* |
|
100
|
7
|
50
|
|
|
|
42
|
: (); |
|
101
|
|
|
|
|
|
|
|
|
102
|
7
|
|
|
|
|
17
|
foreach my $override (@overrides) { |
|
103
|
8
|
50
|
|
|
|
26
|
next unless ref $override eq 'HASH'; |
|
104
|
|
|
|
|
|
|
|
|
105
|
8
|
|
|
|
|
18
|
my $field_name = $override->{field_name}; |
|
106
|
8
|
50
|
|
|
|
20
|
unless ($field_name) { |
|
107
|
0
|
|
|
|
|
0
|
carp "Field override missing field_name; skipping"; |
|
108
|
0
|
|
|
|
|
0
|
next; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# Check if field is protected |
|
112
|
|
|
|
|
|
|
# if ($protected_fields{$field_name}) { |
|
113
|
8
|
100
|
|
|
|
63
|
if ( $field_name =~ /user_id|created_date|last_mod_date/) { |
|
114
|
3
|
|
|
|
|
836
|
carp "Cannot override protected field '$field_name'; skipping"; |
|
115
|
3
|
|
|
|
|
21
|
next; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# Check if field exists in merged_definitions |
|
119
|
5
|
50
|
|
|
|
16
|
unless ($merged_definitions{$field_name}) { |
|
120
|
0
|
|
|
|
|
0
|
carp "Cannot override unknown field '$field_name'; field must be included via include_standard_fields or app_fields"; |
|
121
|
0
|
|
|
|
|
0
|
next; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# Process each attribute in the override |
|
125
|
5
|
|
|
|
|
10
|
my %warnings; |
|
126
|
5
|
|
|
|
|
18
|
foreach my $attr (keys %$override) { |
|
127
|
|
|
|
|
|
|
# Skip field_name itself (it's the identifier, not an attribute to override) |
|
128
|
14
|
100
|
|
|
|
30
|
next if $attr eq 'field_name'; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# Skip protected attributes |
|
131
|
|
|
|
|
|
|
# if ($protected_attrs{$attr}) { |
|
132
|
9
|
50
|
|
|
|
25
|
if ($attr =~ /field_name|category/) { |
|
133
|
0
|
|
|
|
|
0
|
$warnings{$attr} = "protected attribute '$attr' cannot be changed"; |
|
134
|
0
|
|
|
|
|
0
|
next; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# Validate validate_as against known types |
|
138
|
9
|
100
|
|
|
|
19
|
if ($attr eq 'validate_as') { |
|
139
|
1
|
|
|
|
|
4
|
my $validator_type = $override->{$attr}; |
|
140
|
|
|
|
|
|
|
# unless ($known_validators{$validator_type}) { |
|
141
|
1
|
50
|
|
|
|
6
|
unless ($Concierge::Users::Meta::type_validator_map{$validator_type}) { |
|
142
|
1
|
|
|
|
|
17
|
$warnings{$attr} = "unknown validator type '$validator_type' - falling back to 'text'"; |
|
143
|
1
|
|
|
|
|
4
|
$merged_definitions{$field_name}{$attr} = 'text'; |
|
144
|
1
|
|
|
|
|
4
|
next; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# Apply the override |
|
149
|
8
|
|
|
|
|
16
|
$merged_definitions{$field_name}{$attr} = $override->{$attr}; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# Auto-update validate_as when type is changed (unless validate_as was also explicitly overridden) |
|
153
|
5
|
100
|
66
|
|
|
21
|
if (exists $override->{type} && !exists $override->{validate_as}) { |
|
154
|
1
|
|
|
|
|
2
|
my $new_type = $override->{type}; |
|
155
|
|
|
|
|
|
|
# if ($known_validators{$new_type}) { |
|
156
|
1
|
50
|
|
|
|
4
|
if ($Concierge::Users::Meta::type_validator_map{$new_type}) { |
|
157
|
1
|
|
|
|
|
2
|
$merged_definitions{$field_name}{validate_as} = $new_type; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Auto-update must_validate when required is set to 1 (unless must_validate was explicitly overridden) |
|
162
|
5
|
50
|
66
|
|
|
24
|
if (exists $override->{required} && $override->{required} == 1 && !exists $override->{must_validate}) { |
|
|
|
|
66
|
|
|
|
|
|
163
|
1
|
|
|
|
|
2
|
$merged_definitions{$field_name}{must_validate} = 1; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# Emit warnings if any |
|
167
|
5
|
100
|
|
|
|
18
|
if (%warnings) { |
|
168
|
1
|
|
|
|
|
5
|
my $warning_list = join(', ', map { "$_: $warnings{$_}" } sort keys %warnings); |
|
|
1
|
|
|
|
|
7
|
|
|
169
|
1
|
|
|
|
|
312
|
carp "Field '$field_name' override: $warning_list"; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# Add app's supplementary fields and merge their definitions |
|
175
|
|
|
|
|
|
|
# But don't allow use of existing field names |
|
176
|
71
|
100
|
|
|
|
292
|
if ($config->{app_fields}) { |
|
177
|
12
|
|
|
|
|
40
|
my %reserved_fields = map { $_ => 1 } |
|
|
216
|
|
|
|
|
461
|
|
|
178
|
|
|
|
|
|
|
@standard_fields, @core_fields, @system_fields; |
|
179
|
12
|
|
|
|
|
40
|
my @app_fields; |
|
180
|
12
|
50
|
|
|
|
61
|
if (ref $config->{app_fields} eq 'ARRAY' ) { |
|
|
|
0
|
|
|
|
|
|
|
181
|
12
|
|
|
|
|
62
|
@app_fields = $config->{app_fields}->@*; |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
elsif (!ref $config->{app_fields} ) { |
|
184
|
0
|
|
|
|
|
0
|
@app_fields = map { lc $_ } split /\s*[,;]\s*/ => $config->{app_fields}; |
|
|
0
|
|
|
|
|
0
|
|
|
185
|
|
|
|
|
|
|
} |
|
186
|
12
|
|
|
|
|
43
|
FIELD: foreach my $field_def (@app_fields) { |
|
187
|
18
|
|
|
|
|
43
|
my $field_name; |
|
188
|
|
|
|
|
|
|
my $field_definition; |
|
189
|
18
|
100
|
|
|
|
70
|
if (ref $field_def eq 'HASH') { |
|
|
|
50
|
|
|
|
|
|
|
190
|
10
|
|
|
|
|
26
|
$field_name = $field_def->{field_name}; |
|
191
|
10
|
50
|
|
|
|
32
|
if ($reserved_fields{$field_name}) { |
|
192
|
0
|
|
|
|
|
0
|
carp "Supplemental field name $field_name already in use"; |
|
193
|
0
|
|
|
|
|
0
|
next FIELD; |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
# Build complete definition for app field |
|
196
|
|
|
|
|
|
|
$field_definition = { |
|
197
|
|
|
|
|
|
|
field_name => $field_name, |
|
198
|
|
|
|
|
|
|
label => delete $field_def->{label} || labelize($field_name), |
|
199
|
|
|
|
|
|
|
category => 'app', |
|
200
|
|
|
|
|
|
|
# Include all provided attributes (type, default, validation, etc.) |
|
201
|
|
|
|
|
|
|
map { |
|
202
|
18
|
|
|
|
|
80
|
$_ => $field_def->{$_} |
|
203
|
10
|
|
66
|
|
|
61
|
} grep { !/field_name|label|category/ } keys %$field_def |
|
|
28
|
|
|
|
|
144
|
|
|
204
|
|
|
|
|
|
|
}; |
|
205
|
10
|
|
100
|
|
|
74
|
$field_definition->{required} ||= 0; |
|
206
|
10
|
50
|
|
|
|
31
|
unless ( exists $field_definition->{null_value} ) { |
|
207
|
10
|
|
50
|
|
|
78
|
$field_definition->{null_value} = $Concierge::Users::Meta::type_null_values{ $field_def->{type} || 'text' }; |
|
208
|
|
|
|
|
|
|
} |
|
209
|
|
|
|
|
|
|
} elsif ( !ref $field_def ) { |
|
210
|
|
|
|
|
|
|
# Simple string field name - create minimal definition |
|
211
|
8
|
|
|
|
|
20
|
$field_name = $field_def; |
|
212
|
8
|
100
|
|
|
|
40
|
if ($reserved_fields{$field_name}) { |
|
213
|
2
|
|
|
|
|
364
|
carp "Supplemental field name $field_name already in use"; |
|
214
|
2
|
|
|
|
|
10
|
next FIELD; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
$field_definition = { |
|
217
|
6
|
|
|
|
|
23
|
field_name => $field_name, |
|
218
|
|
|
|
|
|
|
label => labelize($field_name), |
|
219
|
|
|
|
|
|
|
category => 'app', |
|
220
|
|
|
|
|
|
|
type => 'text', # Default type |
|
221
|
|
|
|
|
|
|
validate_as => 'text', # Default validation |
|
222
|
|
|
|
|
|
|
required => 0, |
|
223
|
|
|
|
|
|
|
null_value => '', |
|
224
|
|
|
|
|
|
|
}; |
|
225
|
|
|
|
|
|
|
} |
|
226
|
16
|
|
|
|
|
49
|
$merged_definitions{$field_name} = $field_definition; |
|
227
|
16
|
|
|
|
|
93
|
push @fields, $field_name; |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
} |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
# Always add system fields |
|
232
|
71
|
|
|
|
|
221
|
push @fields, @system_fields; |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
# Auto-set defaults for enum fields that don't have explicit defaults |
|
235
|
|
|
|
|
|
|
# Also create v_options (validated options) without asterisks for internal use |
|
236
|
71
|
|
|
|
|
359
|
foreach my $field_name (keys %merged_definitions) { |
|
237
|
764
|
|
|
|
|
2236
|
my $def = $merged_definitions{$field_name}; |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
# Process enum options: create v_options without asterisks |
|
240
|
764
|
50
|
66
|
|
|
2339
|
if ($def->{type} eq 'enum' && $def->{options}) { |
|
241
|
|
|
|
|
|
|
# Create clean options list for validation (strip leading asterisk and any following spaces) |
|
242
|
178
|
|
|
|
|
487
|
my @clean_options = map { s/^\*\s*//r } $def->{options}->@*; |
|
|
913
|
|
|
|
|
2465
|
|
|
243
|
178
|
|
|
|
|
595
|
$merged_definitions{$field_name}{v_options} = \@clean_options; |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
# Auto-set default from * designated option for enum fields |
|
246
|
|
|
|
|
|
|
# Check if default is undefined OR empty string (both should trigger auto-set) |
|
247
|
178
|
50
|
33
|
|
|
615
|
if (!$def->{default} || $def->{default} eq '') { |
|
248
|
178
|
|
|
|
|
327
|
my $default_option = ''; |
|
249
|
178
|
|
|
|
|
403
|
for my $opt ($def->{options}->@*) { |
|
250
|
480
|
100
|
|
|
|
1293
|
if ($opt =~ /^\*(.+)\s*$/) { |
|
251
|
145
|
|
|
|
|
395
|
$default_option = $1; # OK if it's '' |
|
252
|
145
|
|
|
|
|
321
|
last; |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
} |
|
255
|
178
|
|
|
|
|
630
|
$merged_definitions{$field_name}{default} = $default_option; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
} |
|
258
|
|
|
|
|
|
|
} |
|
259
|
|
|
|
|
|
|
|
|
260
|
71
|
|
|
|
|
985
|
my %field_meta = ( |
|
261
|
|
|
|
|
|
|
fields => [ @fields ], |
|
262
|
|
|
|
|
|
|
field_definitions => { %merged_definitions }, |
|
263
|
|
|
|
|
|
|
); |
|
264
|
|
|
|
|
|
|
|
|
265
|
71
|
|
|
|
|
754
|
return \%field_meta; |
|
266
|
|
|
|
|
|
|
} |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
# Type-to-validator mapping for default validation |
|
269
|
|
|
|
|
|
|
%Concierge::Users::Meta::type_validator_map = ( |
|
270
|
|
|
|
|
|
|
text => \&validate_text, |
|
271
|
|
|
|
|
|
|
enum => \&validate_enum, |
|
272
|
|
|
|
|
|
|
boolean => \&validate_boolean, |
|
273
|
|
|
|
|
|
|
date => \&validate_date, |
|
274
|
|
|
|
|
|
|
timestamp => \&validate_timestamp, |
|
275
|
|
|
|
|
|
|
email => \&validate_email, |
|
276
|
|
|
|
|
|
|
phone => \&validate_phone, |
|
277
|
|
|
|
|
|
|
integer => \&validate_integer, |
|
278
|
|
|
|
|
|
|
moniker => \&validate_moniker, |
|
279
|
|
|
|
|
|
|
name => \&validate_name_field, |
|
280
|
|
|
|
|
|
|
); |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
%Concierge::Users::Meta::type_null_values = ( |
|
283
|
|
|
|
|
|
|
text => '', |
|
284
|
|
|
|
|
|
|
enum => '', |
|
285
|
|
|
|
|
|
|
boolean => '', |
|
286
|
|
|
|
|
|
|
date => '0000-00-00', |
|
287
|
|
|
|
|
|
|
timestamp => '0000-00-00 00:00:00', |
|
288
|
|
|
|
|
|
|
email => '', |
|
289
|
|
|
|
|
|
|
phone => '', |
|
290
|
|
|
|
|
|
|
integer => 0, |
|
291
|
|
|
|
|
|
|
moniker => '', |
|
292
|
|
|
|
|
|
|
name => '', |
|
293
|
|
|
|
|
|
|
); |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
# Get field validator - returns validator based on validate_as or type |
|
296
|
|
|
|
|
|
|
sub get_field_validator { |
|
297
|
161
|
|
|
161
|
1
|
475
|
my ($self, $field) = @_; |
|
298
|
|
|
|
|
|
|
|
|
299
|
161
|
|
|
|
|
555
|
my $field_def = $self->get_field_definition($field); |
|
300
|
161
|
50
|
|
|
|
509
|
return unless $field_def; |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
# Check for validate_as specifier (JSON-serializable) |
|
303
|
161
|
100
|
|
|
|
633
|
if ($field_def->{validate_as}) { |
|
304
|
160
|
|
|
|
|
459
|
my $validator_type = $field_def->{validate_as}; |
|
305
|
|
|
|
|
|
|
return $Concierge::Users::Meta::type_validator_map{$validator_type} |
|
306
|
160
|
50
|
|
|
|
1007
|
if $Concierge::Users::Meta::type_validator_map{$validator_type}; |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
# Return type-derived validator if available |
|
310
|
1
|
|
|
|
|
3
|
my $type = $field_def->{type}; |
|
311
|
|
|
|
|
|
|
return $Concierge::Users::Meta::type_validator_map{$type} |
|
312
|
1
|
50
|
33
|
|
|
12
|
if $type && $Concierge::Users::Meta::type_validator_map{$type}; |
|
313
|
|
|
|
|
|
|
|
|
314
|
0
|
|
|
|
|
0
|
return; # No validator available |
|
315
|
|
|
|
|
|
|
} |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
# Get UI-friendly field hints for calling applications |
|
318
|
|
|
|
|
|
|
# Returns hashref with: label, type, max_length, options, description, required |
|
319
|
|
|
|
|
|
|
sub get_field_hints { |
|
320
|
2
|
|
|
2
|
1
|
3164
|
my ($self, $field) = @_; |
|
321
|
|
|
|
|
|
|
|
|
322
|
2
|
|
|
|
|
14
|
my $field_def = $self->get_field_definition($field); |
|
323
|
2
|
50
|
|
|
|
10
|
return unless $field_def; |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
return { |
|
326
|
|
|
|
|
|
|
label => $field_def->{label} || labelize($field_def->{field_name} || $field), |
|
327
|
|
|
|
|
|
|
type => $field_def->{type}, |
|
328
|
|
|
|
|
|
|
max_length => $field_def->{max_length}, |
|
329
|
|
|
|
|
|
|
options => $field_def->{options}, |
|
330
|
|
|
|
|
|
|
description => $field_def->{description}, |
|
331
|
|
|
|
|
|
|
required => $field_def->{required}, |
|
332
|
2
|
|
33
|
|
|
53
|
}; |
|
333
|
|
|
|
|
|
|
} |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
# Get the list of field names for this user object |
|
336
|
|
|
|
|
|
|
sub get_user_fields { |
|
337
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
338
|
|
|
|
|
|
|
|
|
339
|
0
|
|
|
|
|
0
|
return $self->{fields}; |
|
340
|
|
|
|
|
|
|
} |
|
341
|
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
# Auto-generate label from field_name |
|
343
|
|
|
|
|
|
|
sub labelize { |
|
344
|
15
|
|
|
15
|
0
|
41
|
my ($field_name) = @_; |
|
345
|
15
|
50
|
|
|
|
43
|
return unless $field_name; |
|
346
|
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
# Convert underscore_case to Title Case |
|
348
|
15
|
|
|
|
|
75
|
$field_name =~ s/_/ /g; |
|
349
|
15
|
|
|
|
|
189
|
$field_name =~ s/\b(\w)/\u$1/g; |
|
350
|
|
|
|
|
|
|
|
|
351
|
15
|
|
|
|
|
119
|
return $field_name; |
|
352
|
|
|
|
|
|
|
} |
|
353
|
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
# Generate current date in YYYY-MM-DD format |
|
355
|
|
|
|
|
|
|
sub current_date { |
|
356
|
0
|
|
|
0
|
0
|
0
|
my ($mday, $mon, $year) = gmtime; |
|
357
|
0
|
|
|
|
|
0
|
return sprintf("%04d-%02d-%02d", $year + 1900, $mon + 1, $mday); |
|
358
|
|
|
|
|
|
|
} |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
# Generate current timestamp in YYYY-MM-DD HH:MM:SS format |
|
361
|
|
|
|
|
|
|
sub current_timestamp { |
|
362
|
439
|
|
|
439
|
0
|
2442
|
my ($sec, $min, $hour, $mday, $mon, $year) = gmtime; |
|
363
|
439
|
|
|
|
|
4855
|
return sprintf("%04d-%02d-%02d %02d:%02d:%02d", |
|
364
|
|
|
|
|
|
|
$year + 1900, $mon + 1, $mday, $hour, $min, $sec); |
|
365
|
|
|
|
|
|
|
} |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
sub archive_timestamp { |
|
368
|
0
|
|
|
0
|
0
|
0
|
my ($sec, $min, $hour, $mday, $mon, $year) = localtime; |
|
369
|
0
|
|
|
|
|
0
|
return sprintf("%04d%02d%02d_%02d%02d%02d", |
|
370
|
|
|
|
|
|
|
$year + 1900, $mon + 1, $mday, $hour, $min, $sec); |
|
371
|
|
|
|
|
|
|
} |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
# ============================================================================== |
|
374
|
|
|
|
|
|
|
# CONFIG DISPLAY METHODS |
|
375
|
|
|
|
|
|
|
# ============================================================================== |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
# Convert config hash to YAML format for storage |
|
378
|
|
|
|
|
|
|
# Returns YAML string with warning header |
|
379
|
|
|
|
|
|
|
sub config_to_yaml { |
|
380
|
60
|
|
|
60
|
1
|
228
|
my ($config, $storage_dir) = @_; |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
# Build YAML header |
|
383
|
60
|
|
|
|
|
185
|
my $yaml = ''; |
|
384
|
60
|
|
|
|
|
154
|
$yaml .= "#" . ("#" x 78) . "\n"; |
|
385
|
60
|
|
|
|
|
155
|
$yaml .= "# WARNING: This is a GENERATED file for reference ONLY\n"; |
|
386
|
60
|
|
|
|
|
164
|
$yaml .= "#\n"; |
|
387
|
60
|
|
|
|
|
132
|
$yaml .= "# Editing this file will NOT affect your Users setup configuration.\n"; |
|
388
|
60
|
|
|
|
|
132
|
$yaml .= "#\n"; |
|
389
|
60
|
|
|
|
|
135
|
$yaml .= "# This file is automatically generated from:\n"; |
|
390
|
60
|
|
|
|
|
120
|
$yaml .= "# users-config.json\n"; |
|
391
|
60
|
|
|
|
|
112
|
$yaml .= "#\n"; |
|
392
|
60
|
|
|
|
|
149
|
$yaml .= "# This file:\n"; |
|
393
|
60
|
|
|
|
|
132
|
$yaml .= "# $storage_dir/users-config.yaml\n"; |
|
394
|
60
|
|
|
|
|
166
|
$yaml .= "#" . ("#" x 78) . "\n"; |
|
395
|
60
|
|
|
|
|
127
|
$yaml .= "\n"; |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
# Configuration metadata |
|
398
|
60
|
|
|
|
|
112
|
$yaml .= "Configuration:\n"; |
|
399
|
60
|
|
|
|
|
178
|
$yaml .= " Version: $config->{version}\n"; |
|
400
|
60
|
|
|
|
|
205
|
$yaml .= " Backend: $config->{backend_module}\n"; |
|
401
|
60
|
|
|
|
|
172
|
$yaml .= " Storage Directory: $storage_dir\n"; |
|
402
|
60
|
|
|
|
|
155
|
$yaml .= " Generated: $config->{generated}\n"; |
|
403
|
60
|
|
|
|
|
153
|
$yaml .= "\n"; |
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
# Field Definitions |
|
406
|
60
|
|
|
|
|
138
|
$yaml .= "Field Definitions:\n"; |
|
407
|
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
# Organize fields by category |
|
409
|
|
|
|
|
|
|
my %fields_by_category = ( |
|
410
|
645
|
|
|
|
|
1037
|
'Core Fields' => [grep { my $f=$_; grep { $_ eq $f } @Concierge::Users::Meta::core_fields } @{$config->{fields}}], |
|
|
645
|
|
|
|
|
1121
|
|
|
|
2580
|
|
|
|
|
4808
|
|
|
|
60
|
|
|
|
|
260
|
|
|
411
|
645
|
|
|
|
|
1005
|
'Standard Fields' => [grep { my $f=$_; grep { $_ eq $f } @Concierge::Users::Meta::standard_fields } @{$config->{fields}}], |
|
|
645
|
|
|
|
|
1081
|
|
|
|
7740
|
|
|
|
|
13160
|
|
|
|
60
|
|
|
|
|
231
|
|
|
412
|
645
|
|
|
|
|
994
|
'System Fields' => [grep { my $f=$_; grep { $_ eq $f } @Concierge::Users::Meta::system_fields } @{$config->{fields}}], |
|
|
645
|
|
|
|
|
1011
|
|
|
|
1290
|
|
|
|
|
2365
|
|
|
|
60
|
|
|
|
|
206
|
|
|
413
|
645
|
|
|
|
|
1111
|
'Application Fields' => [grep { my $f=$_; my $found=0; |
|
|
645
|
|
|
|
|
950
|
|
|
414
|
645
|
|
|
|
|
1370
|
for my $cat (\@Concierge::Users::Meta::core_fields, \@Concierge::Users::Meta::standard_fields, \@Concierge::Users::Meta::system_fields) { |
|
415
|
1935
|
100
|
|
|
|
3163
|
$found = 1 if grep { $_ eq $f } @$cat; |
|
|
11610
|
|
|
|
|
20832
|
|
|
416
|
|
|
|
|
|
|
} |
|
417
|
645
|
|
|
|
|
1782
|
!$found; |
|
418
|
60
|
|
|
|
|
181
|
} @{$config->{fields}}], |
|
|
60
|
|
|
|
|
168
|
|
|
419
|
|
|
|
|
|
|
); |
|
420
|
|
|
|
|
|
|
|
|
421
|
60
|
|
|
|
|
198
|
foreach my $category ('Core Fields', 'Standard Fields', 'System Fields', 'Application Fields') { |
|
422
|
240
|
|
|
|
|
552
|
my $fields = $fields_by_category{$category}; |
|
423
|
240
|
100
|
66
|
|
|
1180
|
next unless $fields && @$fields; |
|
424
|
|
|
|
|
|
|
|
|
425
|
183
|
|
|
|
|
354
|
$yaml .= " $category:\n"; |
|
426
|
183
|
|
|
|
|
400
|
foreach my $field (@$fields) { |
|
427
|
645
|
|
|
|
|
1365
|
my $def = $config->{field_definitions}{$field}; |
|
428
|
645
|
50
|
|
|
|
1267
|
next unless $def; |
|
429
|
|
|
|
|
|
|
|
|
430
|
645
|
|
|
|
|
1039
|
$yaml .= " $field:\n"; |
|
431
|
645
|
|
|
|
|
1159
|
$yaml .= " field_name: $def->{field_name}\n"; |
|
432
|
645
|
|
|
|
|
1203
|
$yaml .= " type: $def->{type}\n"; |
|
433
|
645
|
|
|
|
|
1474
|
$yaml .= " required: $def->{required}\n"; |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
# Only show validate_as if it's different from type |
|
436
|
645
|
100
|
100
|
|
|
2221
|
if ($def->{validate_as} && $def->{validate_as} ne $def->{type}) { |
|
437
|
133
|
|
|
|
|
245
|
$yaml .= " validate_as: $def->{validate_as}\n"; |
|
438
|
|
|
|
|
|
|
} |
|
439
|
|
|
|
|
|
|
|
|
440
|
645
|
|
|
|
|
1376
|
$yaml .= " default: " . _yaml_scalar_value($def->{default}) . "\n"; |
|
441
|
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
# Show options if present |
|
443
|
645
|
100
|
100
|
|
|
1597
|
if ($def->{options} && @{$def->{options}}) { |
|
|
641
|
|
|
|
|
2175
|
|
|
444
|
148
|
|
|
|
|
276
|
$yaml .= " options: (asterisk '*' designates default option)\n"; |
|
445
|
148
|
|
|
|
|
227
|
foreach my $opt (@{$def->{options}}) { |
|
|
148
|
|
|
|
|
365
|
|
|
446
|
756
|
|
|
|
|
1267
|
$yaml .= " - $opt\n"; |
|
447
|
|
|
|
|
|
|
} |
|
448
|
|
|
|
|
|
|
} |
|
449
|
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
# Show description if present |
|
451
|
645
|
100
|
|
|
|
1500
|
if ($def->{description}) { |
|
452
|
640
|
|
|
|
|
1136
|
$yaml .= " description: \"$def->{description}\"\n"; |
|
453
|
|
|
|
|
|
|
} |
|
454
|
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
# Show other key attributes if present |
|
456
|
645
|
100
|
|
|
|
1902
|
$yaml .= " max_length: $def->{max_length}\n" if $def->{max_length}; |
|
457
|
645
|
100
|
|
|
|
1465
|
$yaml .= " must_validate: $def->{must_validate}\n" if $def->{must_validate}; |
|
458
|
645
|
|
|
|
|
1260
|
$yaml .= " null_value: " . _yaml_scalar_value($def->{null_value}) . "\n"; |
|
459
|
|
|
|
|
|
|
|
|
460
|
645
|
|
|
|
|
1317
|
$yaml .= "\n"; |
|
461
|
|
|
|
|
|
|
} |
|
462
|
|
|
|
|
|
|
} |
|
463
|
|
|
|
|
|
|
|
|
464
|
60
|
|
|
|
|
619
|
return $yaml; |
|
465
|
|
|
|
|
|
|
} |
|
466
|
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
# Helper to properly quote YAML scalar values |
|
468
|
|
|
|
|
|
|
sub _yaml_scalar_value { |
|
469
|
1290
|
|
|
1290
|
|
2259
|
my ($value) = @_; |
|
470
|
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
# Handle undefined values |
|
472
|
1290
|
100
|
|
|
|
2557
|
return 'null' unless defined $value; |
|
473
|
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
# Handle empty strings |
|
475
|
1286
|
100
|
|
|
|
2992
|
return '""' if $value eq ''; |
|
476
|
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
# Handle numeric values |
|
478
|
402
|
100
|
|
|
|
1654
|
return $value if $value =~ /^\-?\d+$/; |
|
479
|
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
# Handle boolean |
|
481
|
401
|
50
|
|
|
|
1072
|
return $value if $value =~ /^[01]$/; |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
# Quote strings with spaces or special chars |
|
484
|
401
|
100
|
|
|
|
1352
|
return $value if $value =~ /^\S+$/; |
|
485
|
266
|
|
|
|
|
609
|
return "\"$value\""; |
|
486
|
|
|
|
|
|
|
} |
|
487
|
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
# Show default configuration (from __DATA__ section) |
|
489
|
|
|
|
|
|
|
# Can be called as class method or instance method |
|
490
|
|
|
|
|
|
|
# Parameters (optional hash): |
|
491
|
|
|
|
|
|
|
# output_path => '/path/to/file.yaml' # Save to file instead of STDOUT |
|
492
|
|
|
|
|
|
|
sub show_default_config { |
|
493
|
0
|
|
|
0
|
1
|
0
|
my ($self, %params) = @_; |
|
494
|
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
# Read from __DATA__ section |
|
496
|
0
|
|
|
|
|
0
|
my @data = ; |
|
497
|
0
|
|
|
|
|
0
|
say @data; |
|
498
|
|
|
|
|
|
|
} |
|
499
|
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
# Show configuration for an existing setup |
|
501
|
|
|
|
|
|
|
# Must be called as instance method on a Users object |
|
502
|
|
|
|
|
|
|
# Parameters (optional hash): |
|
503
|
|
|
|
|
|
|
# output_path => '/path/to/file.yaml' # Save to different location |
|
504
|
|
|
|
|
|
|
sub show_config { |
|
505
|
0
|
|
|
0
|
1
|
0
|
my ($self, %params) = @_; |
|
506
|
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
# Check if this is a valid Users object with storage_dir |
|
508
|
0
|
0
|
0
|
|
|
0
|
unless (ref $self && $self->{backend}) { |
|
509
|
|
|
|
|
|
|
return { |
|
510
|
0
|
|
|
|
|
0
|
success => 0, |
|
511
|
|
|
|
|
|
|
message => "show_config() must be called on a Users instance. " |
|
512
|
|
|
|
|
|
|
. "Use show_default_config() to view default configuration." |
|
513
|
|
|
|
|
|
|
}; |
|
514
|
|
|
|
|
|
|
} |
|
515
|
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
# Get storage_dir from backend config |
|
517
|
|
|
|
|
|
|
my $storage_dir = $self->{backend}{storage_dir} |
|
518
|
|
|
|
|
|
|
or return { |
|
519
|
0
|
0
|
|
|
|
0
|
success => 0, |
|
520
|
|
|
|
|
|
|
message => "Cannot determine storage directory from Users object" |
|
521
|
|
|
|
|
|
|
}; |
|
522
|
|
|
|
|
|
|
|
|
523
|
0
|
|
0
|
|
|
0
|
my $yaml_file = $params{output_path} || "$storage_dir/users-config.yaml"; |
|
524
|
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
# Check if YAML config file exists |
|
526
|
0
|
0
|
|
|
|
0
|
unless (-f $yaml_file) { |
|
527
|
|
|
|
|
|
|
return { |
|
528
|
0
|
|
|
|
|
0
|
success => 0, |
|
529
|
|
|
|
|
|
|
message => "Configuration file not found: $yaml_file\n" |
|
530
|
|
|
|
|
|
|
. "Note: YAML config files are created automatically during setup().\n" |
|
531
|
|
|
|
|
|
|
. "If you just created this setup, the file should exist. " |
|
532
|
|
|
|
|
|
|
. "Otherwise, the setup may be incomplete." |
|
533
|
|
|
|
|
|
|
}; |
|
534
|
|
|
|
|
|
|
} |
|
535
|
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
# Read and display the YAML file |
|
537
|
0
|
|
|
|
|
0
|
my $yaml_content; |
|
538
|
0
|
|
|
|
|
0
|
eval { |
|
539
|
0
|
0
|
|
|
|
0
|
open my $fh, '<', $yaml_file or croak "Cannot open $yaml_file: $!"; |
|
540
|
0
|
|
|
|
|
0
|
local $/; |
|
541
|
0
|
|
|
|
|
0
|
$yaml_content = <$fh>; |
|
542
|
0
|
|
|
|
|
0
|
close $fh; |
|
543
|
|
|
|
|
|
|
}; |
|
544
|
0
|
0
|
|
|
|
0
|
if ($@) { |
|
545
|
|
|
|
|
|
|
return { |
|
546
|
0
|
|
|
|
|
0
|
success => 0, |
|
547
|
|
|
|
|
|
|
message => "Failed to read configuration file: $@" |
|
548
|
|
|
|
|
|
|
}; |
|
549
|
|
|
|
|
|
|
} |
|
550
|
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
# Print to STDOUT |
|
552
|
0
|
|
|
|
|
0
|
print $yaml_content; |
|
553
|
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
return { |
|
555
|
0
|
|
|
|
|
0
|
success => 1, |
|
556
|
|
|
|
|
|
|
message => "Configuration displayed from $yaml_file", |
|
557
|
|
|
|
|
|
|
config_file => $yaml_file |
|
558
|
|
|
|
|
|
|
}; |
|
559
|
|
|
|
|
|
|
} |
|
560
|
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
# ============================================================================== |
|
563
|
|
|
|
|
|
|
# VALIDATOR METHODS |
|
564
|
|
|
|
|
|
|
# All validators receive: ($user_data, $field_name, $field_def) |
|
565
|
|
|
|
|
|
|
# Validators modify $user_data->{$field_name} directly if substitution needed |
|
566
|
|
|
|
|
|
|
# All validators return: { success => 1|0, message => "..." } |
|
567
|
|
|
|
|
|
|
# ============================================================================== |
|
568
|
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
# Validate enum fields against options |
|
570
|
|
|
|
|
|
|
sub validate_enum { |
|
571
|
7
|
|
|
7
|
0
|
19
|
my ($user_data, $field_name, $field_def) = @_; |
|
572
|
|
|
|
|
|
|
|
|
573
|
7
|
|
|
|
|
17
|
my $value = $user_data->{$field_name}; |
|
574
|
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
# Use v_options (validated options without asterisks) |
|
576
|
7
|
|
50
|
|
|
60
|
my $options = $field_def->{v_options} || []; |
|
577
|
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
# Check if value is in the allowed options |
|
579
|
7
|
100
|
|
|
|
35
|
if (grep { $_ eq $value } @$options) { |
|
|
27
|
|
|
|
|
73
|
|
|
580
|
5
|
|
|
|
|
21
|
return { success => 1 }; |
|
581
|
|
|
|
|
|
|
} |
|
582
|
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
return { |
|
584
|
2
|
|
|
|
|
21
|
success => 0, |
|
585
|
|
|
|
|
|
|
message => "$field_def->{label} must be one of: " . join(', ', @$options), |
|
586
|
|
|
|
|
|
|
}; |
|
587
|
|
|
|
|
|
|
} |
|
588
|
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
# Validate text fields with length checking |
|
590
|
|
|
|
|
|
|
sub validate_text { |
|
591
|
3
|
|
|
3
|
0
|
10
|
my ($user_data, $field_name, $field_def) = @_; |
|
592
|
|
|
|
|
|
|
|
|
593
|
3
|
|
|
|
|
10
|
my $value = $user_data->{$field_name}; |
|
594
|
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
# Check max_length |
|
596
|
3
|
100
|
66
|
|
|
25
|
if ($field_def->{max_length} && length($value) > $field_def->{max_length}) { |
|
597
|
|
|
|
|
|
|
return { |
|
598
|
2
|
|
|
|
|
19
|
success => 0, |
|
599
|
|
|
|
|
|
|
message => "$field_def->{label} must not exceed maximum length of $field_def->{max_length} characters" |
|
600
|
|
|
|
|
|
|
}; |
|
601
|
|
|
|
|
|
|
} |
|
602
|
|
|
|
|
|
|
|
|
603
|
1
|
|
|
|
|
5
|
return { success => 1 }; |
|
604
|
|
|
|
|
|
|
} |
|
605
|
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
# Validate email format |
|
607
|
|
|
|
|
|
|
sub validate_email { |
|
608
|
110
|
|
|
110
|
0
|
410
|
my ($user_data, $field_name, $field_def) = @_; |
|
609
|
|
|
|
|
|
|
|
|
610
|
110
|
|
|
|
|
330
|
my $value = $user_data->{$field_name}; |
|
611
|
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
# Check email format |
|
613
|
110
|
100
|
|
|
|
1195
|
if ($value =~ /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/) { |
|
614
|
108
|
|
|
|
|
574
|
return { success => 1 }; |
|
615
|
|
|
|
|
|
|
} |
|
616
|
|
|
|
|
|
|
|
|
617
|
2
|
|
|
|
|
8
|
return { success => 0, message => "$field_def->{label} must be a valid email address" }; |
|
618
|
|
|
|
|
|
|
} |
|
619
|
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
# Validate date format |
|
621
|
|
|
|
|
|
|
sub validate_date { |
|
622
|
0
|
|
|
0
|
0
|
0
|
my ($user_data, $field_name, $field_def) = @_; |
|
623
|
|
|
|
|
|
|
|
|
624
|
0
|
|
|
|
|
0
|
my $value = $user_data->{$field_name}; |
|
625
|
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
# Check YYYY-MM-DD format |
|
627
|
0
|
0
|
|
|
|
0
|
if ($value =~ /^\d{4}-\d{2}-\d{2}$/) { |
|
628
|
0
|
|
|
|
|
0
|
return { success => 1 }; |
|
629
|
|
|
|
|
|
|
} |
|
630
|
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
return { |
|
632
|
0
|
|
|
|
|
0
|
success => 0, |
|
633
|
|
|
|
|
|
|
message => "Invalid date format for $field_def->{label}", |
|
634
|
|
|
|
|
|
|
}; |
|
635
|
|
|
|
|
|
|
} |
|
636
|
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
# Validate timestamp format |
|
638
|
|
|
|
|
|
|
sub validate_timestamp { |
|
639
|
0
|
|
|
0
|
0
|
0
|
my ($user_data, $field_name, $field_def) = @_; |
|
640
|
|
|
|
|
|
|
|
|
641
|
0
|
|
|
|
|
0
|
my $value = $user_data->{$field_name}; |
|
642
|
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
# Check YYYY-MM-DD HH:MM:SS format |
|
644
|
0
|
0
|
|
|
|
0
|
if ($value =~ /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}$/) { |
|
645
|
0
|
|
|
|
|
0
|
return { success => 1 }; |
|
646
|
|
|
|
|
|
|
} |
|
647
|
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
return { |
|
649
|
0
|
|
|
|
|
0
|
success => 0, |
|
650
|
|
|
|
|
|
|
message => "Invalid timestamp format for $field_def->{label}, using null value" |
|
651
|
|
|
|
|
|
|
}; |
|
652
|
|
|
|
|
|
|
} |
|
653
|
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
# Validate boolean (1|0) # or resolves Perl true/false? |
|
655
|
|
|
|
|
|
|
sub validate_boolean { |
|
656
|
0
|
|
|
0
|
0
|
0
|
my ($user_data, $field_name, $field_def) = @_; |
|
657
|
|
|
|
|
|
|
|
|
658
|
0
|
|
|
|
|
0
|
my $value = $user_data->{$field_name}; |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
# Check if value is explicitly 0 or 1 |
|
661
|
0
|
0
|
0
|
|
|
0
|
if (defined $value && $value =~ /^[01]$/) { |
|
662
|
0
|
|
|
|
|
0
|
return { success => 1 }; |
|
663
|
|
|
|
|
|
|
} |
|
664
|
|
|
|
|
|
|
# Invalid boolean |
|
665
|
|
|
|
|
|
|
return { |
|
666
|
0
|
|
|
|
|
0
|
success => 0, |
|
667
|
|
|
|
|
|
|
message => "Invalid value '$value' for boolean $field_def->{label}" |
|
668
|
|
|
|
|
|
|
}; |
|
669
|
|
|
|
|
|
|
} |
|
670
|
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
# Validate phone format |
|
672
|
|
|
|
|
|
|
sub validate_phone { |
|
673
|
23
|
|
|
23
|
0
|
66
|
my ($user_data, $field_name, $field_def) = @_; |
|
674
|
|
|
|
|
|
|
|
|
675
|
23
|
|
|
|
|
63
|
my $value = $user_data->{$field_name}; |
|
676
|
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
# Check phone format |
|
678
|
23
|
100
|
66
|
|
|
313
|
if ($value =~ /^\+?[\d\s\-\(\)]+$/ && length($value) >= 7) { |
|
679
|
21
|
|
|
|
|
91
|
return { success => 1 }; |
|
680
|
|
|
|
|
|
|
} |
|
681
|
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
# Invalid phone |
|
683
|
2
|
|
|
|
|
14
|
return { success => 0, message => "$field_def->{label} must be a valid 10-character phone number" }; |
|
684
|
|
|
|
|
|
|
} |
|
685
|
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
# Validate integer |
|
687
|
|
|
|
|
|
|
sub validate_integer { |
|
688
|
0
|
|
|
0
|
0
|
0
|
my ($user_data, $field_name, $field_def) = @_; |
|
689
|
|
|
|
|
|
|
|
|
690
|
0
|
|
|
|
|
0
|
my $value = $user_data->{$field_name}; |
|
691
|
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
# Check integer format (allow negative numbers) |
|
693
|
0
|
0
|
|
|
|
0
|
if ($value =~ /^\-?\d+$/) { |
|
694
|
0
|
|
|
|
|
0
|
return { success => 1 }; |
|
695
|
|
|
|
|
|
|
} |
|
696
|
|
|
|
|
|
|
|
|
697
|
0
|
|
|
|
|
0
|
return { success => 0, message => "$field_def->{label} must be a whole number" }; |
|
698
|
|
|
|
|
|
|
} |
|
699
|
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
sub validate_moniker { |
|
701
|
2
|
|
|
2
|
0
|
8
|
my ($user_data, $field_name, $field_def) = @_; |
|
702
|
|
|
|
|
|
|
|
|
703
|
2
|
|
|
|
|
5
|
my $value = $user_data->{$field_name}; |
|
704
|
|
|
|
|
|
|
|
|
705
|
2
|
100
|
66
|
|
|
32
|
return { success => 0, message => "moniker is required as 2-24 alphanumeric characters, no spaces" } |
|
706
|
|
|
|
|
|
|
unless $value && $value =~ /^[a-zA-Z0-9]{2,24}$/; |
|
707
|
|
|
|
|
|
|
|
|
708
|
1
|
|
|
|
|
5
|
return { success => 1 }; |
|
709
|
|
|
|
|
|
|
} |
|
710
|
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
sub validate_name_field { |
|
712
|
16
|
|
|
16
|
0
|
41
|
my ($user_data, $field_name, $field_def) = @_; |
|
713
|
|
|
|
|
|
|
|
|
714
|
16
|
|
|
|
|
38
|
my $value = $user_data->{$field_name}; |
|
715
|
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
# Allow letters, hyphens, apostrophes, and internal spaces |
|
717
|
16
|
100
|
66
|
|
|
137
|
return { success => 0, message => "$field_def->{label} contains invalid characters" } |
|
718
|
|
|
|
|
|
|
unless $value |
|
719
|
|
|
|
|
|
|
&& $value =~ /^[a-zA-Z\u00C0-\u024F'’\-.]+(?:\s+[a-zA-Z\u00C0-\u024F'’\-.]+)*$/; |
|
720
|
|
|
|
|
|
|
|
|
721
|
15
|
|
|
|
|
49
|
return { success => 1 }; |
|
722
|
|
|
|
|
|
|
} |
|
723
|
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
@Concierge::Users::Meta::core_fields = ( qw/ |
|
725
|
|
|
|
|
|
|
user_id |
|
726
|
|
|
|
|
|
|
moniker |
|
727
|
|
|
|
|
|
|
user_status |
|
728
|
|
|
|
|
|
|
access_level |
|
729
|
|
|
|
|
|
|
/ ); |
|
730
|
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
@Concierge::Users::Meta::standard_fields = ( qw/ |
|
732
|
|
|
|
|
|
|
first_name |
|
733
|
|
|
|
|
|
|
middle_name |
|
734
|
|
|
|
|
|
|
last_name |
|
735
|
|
|
|
|
|
|
prefix |
|
736
|
|
|
|
|
|
|
suffix |
|
737
|
|
|
|
|
|
|
organization |
|
738
|
|
|
|
|
|
|
title |
|
739
|
|
|
|
|
|
|
email |
|
740
|
|
|
|
|
|
|
phone |
|
741
|
|
|
|
|
|
|
text_ok |
|
742
|
|
|
|
|
|
|
last_login_date |
|
743
|
|
|
|
|
|
|
term_ends |
|
744
|
|
|
|
|
|
|
/ ); |
|
745
|
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
@Concierge::Users::Meta::system_fields = ( qw/ |
|
747
|
|
|
|
|
|
|
last_mod_date |
|
748
|
|
|
|
|
|
|
created_date |
|
749
|
|
|
|
|
|
|
/ ); |
|
750
|
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
%Concierge::Users::Meta::field_definitions = ( |
|
752
|
|
|
|
|
|
|
# Core field definitions |
|
753
|
|
|
|
|
|
|
user_id => { |
|
754
|
|
|
|
|
|
|
field_name => 'user_id', |
|
755
|
|
|
|
|
|
|
label => 'User ID', |
|
756
|
|
|
|
|
|
|
description => 'User login ID - Primary authentication identifier', |
|
757
|
|
|
|
|
|
|
type => 'system', |
|
758
|
|
|
|
|
|
|
required => 1, |
|
759
|
|
|
|
|
|
|
options => [], |
|
760
|
|
|
|
|
|
|
default => '', |
|
761
|
|
|
|
|
|
|
null_value => '', |
|
762
|
|
|
|
|
|
|
max_length => 30, |
|
763
|
|
|
|
|
|
|
must_validate => 0, |
|
764
|
|
|
|
|
|
|
}, |
|
765
|
|
|
|
|
|
|
moniker => { |
|
766
|
|
|
|
|
|
|
field_name => 'moniker', |
|
767
|
|
|
|
|
|
|
label => 'Moniker', |
|
768
|
|
|
|
|
|
|
description => 'User\'s preferred display name, nickname, or initials', |
|
769
|
|
|
|
|
|
|
type => 'text', |
|
770
|
|
|
|
|
|
|
required => 1, |
|
771
|
|
|
|
|
|
|
options => [], |
|
772
|
|
|
|
|
|
|
default => '', |
|
773
|
|
|
|
|
|
|
null_value => '', |
|
774
|
|
|
|
|
|
|
max_length => 24, |
|
775
|
|
|
|
|
|
|
validate_as => 'moniker', |
|
776
|
|
|
|
|
|
|
must_validate => 1, |
|
777
|
|
|
|
|
|
|
}, |
|
778
|
|
|
|
|
|
|
user_status => { |
|
779
|
|
|
|
|
|
|
field_name => 'user_status', |
|
780
|
|
|
|
|
|
|
label => 'User Status', |
|
781
|
|
|
|
|
|
|
description => 'Account status for access control', |
|
782
|
|
|
|
|
|
|
type => 'enum', |
|
783
|
|
|
|
|
|
|
required => 1, |
|
784
|
|
|
|
|
|
|
options => ['*Eligible', 'OK', 'Inactive'], |
|
785
|
|
|
|
|
|
|
default => '', # Will be auto-set to option with '*' |
|
786
|
|
|
|
|
|
|
null_value => '', |
|
787
|
|
|
|
|
|
|
max_length => 20, |
|
788
|
|
|
|
|
|
|
validate_as => 'enum', |
|
789
|
|
|
|
|
|
|
must_validate => 1, |
|
790
|
|
|
|
|
|
|
}, |
|
791
|
|
|
|
|
|
|
access_level => { |
|
792
|
|
|
|
|
|
|
field_name => 'access_level', |
|
793
|
|
|
|
|
|
|
label => 'Access Level', |
|
794
|
|
|
|
|
|
|
description => 'Permission level for feature access', |
|
795
|
|
|
|
|
|
|
type => 'enum', |
|
796
|
|
|
|
|
|
|
required => 1, |
|
797
|
|
|
|
|
|
|
options => ['*anon', 'visitor', 'member', 'staff', 'admin'], |
|
798
|
|
|
|
|
|
|
default => '', # Will be auto-set to option with '*' |
|
799
|
|
|
|
|
|
|
null_value => '', |
|
800
|
|
|
|
|
|
|
max_length => 20, |
|
801
|
|
|
|
|
|
|
validate_as => 'enum', |
|
802
|
|
|
|
|
|
|
must_validate => 1, |
|
803
|
|
|
|
|
|
|
}, |
|
804
|
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
# Standard field definitions |
|
806
|
|
|
|
|
|
|
first_name => { |
|
807
|
|
|
|
|
|
|
field_name => 'first_name', |
|
808
|
|
|
|
|
|
|
label => 'First Name', |
|
809
|
|
|
|
|
|
|
description => 'User\'s first name', |
|
810
|
|
|
|
|
|
|
type => 'text', |
|
811
|
|
|
|
|
|
|
required => 0, |
|
812
|
|
|
|
|
|
|
options => [], |
|
813
|
|
|
|
|
|
|
default => '', |
|
814
|
|
|
|
|
|
|
null_value => '', |
|
815
|
|
|
|
|
|
|
max_length => 50, |
|
816
|
|
|
|
|
|
|
validate_as => 'name', |
|
817
|
|
|
|
|
|
|
must_validate => 1, |
|
818
|
|
|
|
|
|
|
}, |
|
819
|
|
|
|
|
|
|
middle_name => { |
|
820
|
|
|
|
|
|
|
field_name => 'middle_name', |
|
821
|
|
|
|
|
|
|
label => 'Middle Name', |
|
822
|
|
|
|
|
|
|
description => 'User\'s middle name', |
|
823
|
|
|
|
|
|
|
type => 'text', |
|
824
|
|
|
|
|
|
|
required => 0, |
|
825
|
|
|
|
|
|
|
options => [], |
|
826
|
|
|
|
|
|
|
default => '', |
|
827
|
|
|
|
|
|
|
null_value => '', |
|
828
|
|
|
|
|
|
|
max_length => 50, |
|
829
|
|
|
|
|
|
|
validate_as => 'name', |
|
830
|
|
|
|
|
|
|
must_validate => 1, |
|
831
|
|
|
|
|
|
|
}, |
|
832
|
|
|
|
|
|
|
last_name => { |
|
833
|
|
|
|
|
|
|
field_name => 'last_name', |
|
834
|
|
|
|
|
|
|
label => 'Last Name', |
|
835
|
|
|
|
|
|
|
description => 'User\'s last name', |
|
836
|
|
|
|
|
|
|
type => 'text', |
|
837
|
|
|
|
|
|
|
required => 0, |
|
838
|
|
|
|
|
|
|
options => [], |
|
839
|
|
|
|
|
|
|
default => '', |
|
840
|
|
|
|
|
|
|
null_value => '', |
|
841
|
|
|
|
|
|
|
max_length => 50, |
|
842
|
|
|
|
|
|
|
validate_as => 'name', |
|
843
|
|
|
|
|
|
|
must_validate => 1, |
|
844
|
|
|
|
|
|
|
}, |
|
845
|
|
|
|
|
|
|
prefix => { |
|
846
|
|
|
|
|
|
|
field_name => 'prefix', |
|
847
|
|
|
|
|
|
|
label => 'Prefix', |
|
848
|
|
|
|
|
|
|
description => 'Name prefix or title', |
|
849
|
|
|
|
|
|
|
type => 'enum', |
|
850
|
|
|
|
|
|
|
required => 0, |
|
851
|
|
|
|
|
|
|
options => ['*', 'Dr', 'Mr', 'Ms', 'Mrs', 'Mx', 'Prof', 'Hon', 'Sir', 'Madam'], |
|
852
|
|
|
|
|
|
|
default => '', |
|
853
|
|
|
|
|
|
|
null_value => '', # Will be auto-set to option with '*' |
|
854
|
|
|
|
|
|
|
max_length => 10, |
|
855
|
|
|
|
|
|
|
validate_as => 'enum', |
|
856
|
|
|
|
|
|
|
must_validate => 0, |
|
857
|
|
|
|
|
|
|
}, |
|
858
|
|
|
|
|
|
|
suffix => { |
|
859
|
|
|
|
|
|
|
field_name => 'suffix', |
|
860
|
|
|
|
|
|
|
label => 'Suffix', |
|
861
|
|
|
|
|
|
|
description => 'Name suffix or professional designation', |
|
862
|
|
|
|
|
|
|
type => 'enum', |
|
863
|
|
|
|
|
|
|
required => 0, |
|
864
|
|
|
|
|
|
|
options => ['*', 'Jr', 'Sr', 'II', 'III', 'IV', 'V', 'PhD', 'MD', 'DDS', 'Esq'], |
|
865
|
|
|
|
|
|
|
default => '', # Will be auto-set to option with '*' |
|
866
|
|
|
|
|
|
|
null_value => '', |
|
867
|
|
|
|
|
|
|
max_length => 10, |
|
868
|
|
|
|
|
|
|
validate_as => 'enum', |
|
869
|
|
|
|
|
|
|
must_validate => 0, |
|
870
|
|
|
|
|
|
|
}, |
|
871
|
|
|
|
|
|
|
organization => { |
|
872
|
|
|
|
|
|
|
field_name => 'organization', |
|
873
|
|
|
|
|
|
|
label => 'Organization', |
|
874
|
|
|
|
|
|
|
description => 'User\'s organization or affiliation', |
|
875
|
|
|
|
|
|
|
type => 'text', |
|
876
|
|
|
|
|
|
|
required => 0, |
|
877
|
|
|
|
|
|
|
options => [], |
|
878
|
|
|
|
|
|
|
default => '', |
|
879
|
|
|
|
|
|
|
null_value => '', |
|
880
|
|
|
|
|
|
|
max_length => 100, |
|
881
|
|
|
|
|
|
|
validate_as => 'text', |
|
882
|
|
|
|
|
|
|
must_validate => 0, |
|
883
|
|
|
|
|
|
|
}, |
|
884
|
|
|
|
|
|
|
title => { |
|
885
|
|
|
|
|
|
|
field_name => 'title', |
|
886
|
|
|
|
|
|
|
label => 'Title', |
|
887
|
|
|
|
|
|
|
description => 'User\'s position or job title', |
|
888
|
|
|
|
|
|
|
type => 'text', |
|
889
|
|
|
|
|
|
|
required => 0, |
|
890
|
|
|
|
|
|
|
options => [], |
|
891
|
|
|
|
|
|
|
default => '', |
|
892
|
|
|
|
|
|
|
null_value => '', |
|
893
|
|
|
|
|
|
|
max_length => 100, |
|
894
|
|
|
|
|
|
|
validate_as => 'text', |
|
895
|
|
|
|
|
|
|
must_validate => 0, |
|
896
|
|
|
|
|
|
|
}, |
|
897
|
|
|
|
|
|
|
email => { |
|
898
|
|
|
|
|
|
|
field_name => 'email', |
|
899
|
|
|
|
|
|
|
label => 'Email', |
|
900
|
|
|
|
|
|
|
description => 'Email address for notifications', |
|
901
|
|
|
|
|
|
|
type => 'email', |
|
902
|
|
|
|
|
|
|
required => 0, |
|
903
|
|
|
|
|
|
|
options => [], |
|
904
|
|
|
|
|
|
|
default => '', |
|
905
|
|
|
|
|
|
|
null_value => '', |
|
906
|
|
|
|
|
|
|
max_length => 255, |
|
907
|
|
|
|
|
|
|
validate_as => 'email', |
|
908
|
|
|
|
|
|
|
must_validate => 0, |
|
909
|
|
|
|
|
|
|
}, |
|
910
|
|
|
|
|
|
|
phone => { |
|
911
|
|
|
|
|
|
|
field_name => 'phone', |
|
912
|
|
|
|
|
|
|
label => 'Phone', |
|
913
|
|
|
|
|
|
|
description => 'Phone number with country code', |
|
914
|
|
|
|
|
|
|
type => 'phone', |
|
915
|
|
|
|
|
|
|
required => 0, |
|
916
|
|
|
|
|
|
|
options => [], |
|
917
|
|
|
|
|
|
|
default => '', |
|
918
|
|
|
|
|
|
|
null_value => '', |
|
919
|
|
|
|
|
|
|
max_length => 20, |
|
920
|
|
|
|
|
|
|
validate_as => 'phone', |
|
921
|
|
|
|
|
|
|
must_validate => 0, |
|
922
|
|
|
|
|
|
|
}, |
|
923
|
|
|
|
|
|
|
text_ok => { |
|
924
|
|
|
|
|
|
|
field_name => 'text_ok', |
|
925
|
|
|
|
|
|
|
label => 'Text OK', |
|
926
|
|
|
|
|
|
|
description => 'Consent for text messages (1=yes, 0=no)', |
|
927
|
|
|
|
|
|
|
type => 'boolean', |
|
928
|
|
|
|
|
|
|
required => 0, |
|
929
|
|
|
|
|
|
|
options => [], |
|
930
|
|
|
|
|
|
|
default => '', |
|
931
|
|
|
|
|
|
|
null_value => '', |
|
932
|
|
|
|
|
|
|
max_length => 1, |
|
933
|
|
|
|
|
|
|
validate_as => 'boolean', |
|
934
|
|
|
|
|
|
|
must_validate => 0, |
|
935
|
|
|
|
|
|
|
}, |
|
936
|
|
|
|
|
|
|
term_ends => { |
|
937
|
|
|
|
|
|
|
field_name => 'term_ends', |
|
938
|
|
|
|
|
|
|
label => 'Term Ends', |
|
939
|
|
|
|
|
|
|
description => 'Account expiration date (YYYY-MM-DD)', |
|
940
|
|
|
|
|
|
|
type => 'date', |
|
941
|
|
|
|
|
|
|
required => 0, |
|
942
|
|
|
|
|
|
|
options => [], |
|
943
|
|
|
|
|
|
|
default => '', |
|
944
|
|
|
|
|
|
|
null_value => '0000-00-00', |
|
945
|
|
|
|
|
|
|
max_length => 10, |
|
946
|
|
|
|
|
|
|
validate_as => 'date', |
|
947
|
|
|
|
|
|
|
must_validate => 0, |
|
948
|
|
|
|
|
|
|
}, |
|
949
|
|
|
|
|
|
|
last_login_date => { |
|
950
|
|
|
|
|
|
|
field_name => 'last_login_date', |
|
951
|
|
|
|
|
|
|
label => 'Last Login Date', |
|
952
|
|
|
|
|
|
|
description => 'Timestamp of last successful login', |
|
953
|
|
|
|
|
|
|
type => 'timestamp', |
|
954
|
|
|
|
|
|
|
required => 0, |
|
955
|
|
|
|
|
|
|
options => [], |
|
956
|
|
|
|
|
|
|
default => '0000-00-00 00:00:00', |
|
957
|
|
|
|
|
|
|
null_value => '0000-00-00 00:00:00', |
|
958
|
|
|
|
|
|
|
max_length => 19, |
|
959
|
|
|
|
|
|
|
validate_as => 'timestamp', |
|
960
|
|
|
|
|
|
|
must_validate => 0, |
|
961
|
|
|
|
|
|
|
}, |
|
962
|
|
|
|
|
|
|
|
|
963
|
|
|
|
|
|
|
# System field definitions |
|
964
|
|
|
|
|
|
|
last_mod_date => { |
|
965
|
|
|
|
|
|
|
field_name => 'last_mod_date', |
|
966
|
|
|
|
|
|
|
label => 'Last Modification Date', |
|
967
|
|
|
|
|
|
|
description => 'Timestamp of last profile modification', |
|
968
|
|
|
|
|
|
|
type => 'system', |
|
969
|
|
|
|
|
|
|
required => 0, |
|
970
|
|
|
|
|
|
|
options => [], |
|
971
|
|
|
|
|
|
|
default => '0000-00-00 00:00:00', |
|
972
|
|
|
|
|
|
|
null_value => '0000-00-00 00:00:00', |
|
973
|
|
|
|
|
|
|
max_length => 19, |
|
974
|
|
|
|
|
|
|
must_validate => 0, |
|
975
|
|
|
|
|
|
|
}, |
|
976
|
|
|
|
|
|
|
created_date => { |
|
977
|
|
|
|
|
|
|
field_name => 'created_date', |
|
978
|
|
|
|
|
|
|
label => 'Created Date', |
|
979
|
|
|
|
|
|
|
description => 'Timestamp when user account was created', |
|
980
|
|
|
|
|
|
|
type => 'system', |
|
981
|
|
|
|
|
|
|
required => 1, |
|
982
|
|
|
|
|
|
|
options => [], |
|
983
|
|
|
|
|
|
|
default => '0000-00-00 00:00:00', |
|
984
|
|
|
|
|
|
|
null_value => '0000-00-00 00:00:00', |
|
985
|
|
|
|
|
|
|
max_length => 19, |
|
986
|
|
|
|
|
|
|
must_validate => 0, |
|
987
|
|
|
|
|
|
|
}, |
|
988
|
|
|
|
|
|
|
); |
|
989
|
|
|
|
|
|
|
|
|
990
|
|
|
|
|
|
|
sub validate_user_data { |
|
991
|
137
|
|
|
137
|
1
|
502
|
my ($self, $user_data) = @_; |
|
992
|
|
|
|
|
|
|
|
|
993
|
|
|
|
|
|
|
return { success => 1, valid_data => $user_data, message => 'Validation skipped per environment variable USERS_SKIP_VALIDATION' } |
|
994
|
137
|
50
|
|
|
|
684
|
if $ENV{USERS_SKIP_VALIDATION}; |
|
995
|
|
|
|
|
|
|
|
|
996
|
137
|
|
|
|
|
286
|
my @warnings; |
|
997
|
137
|
|
|
|
|
441
|
my $validated_data = {}; |
|
998
|
137
|
|
|
|
|
780
|
foreach my ($field, $value) ( $user_data->%* ) { |
|
999
|
|
|
|
|
|
|
# Get field definition |
|
1000
|
179
|
|
|
|
|
957
|
my $field_def = $self->get_field_definition($field); |
|
1001
|
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
# Skip unknown fields with warning |
|
1003
|
179
|
100
|
|
|
|
589
|
unless (defined $field_def) { |
|
1004
|
13
|
|
|
|
|
60
|
push @warnings, "Field '$field' not recognized in schema; input data skipped"; |
|
1005
|
13
|
|
|
|
|
35
|
next; |
|
1006
|
|
|
|
|
|
|
} |
|
1007
|
|
|
|
|
|
|
|
|
1008
|
|
|
|
|
|
|
# Fail if a required field isn't provided a value |
|
1009
|
|
|
|
|
|
|
# or the value is the same as the field's null_value |
|
1010
|
166
|
100
|
66
|
|
|
1320
|
if ( !defined $value or $value eq $field_def->{null_value} ) { |
|
1011
|
|
|
|
|
|
|
return { success => 0, message => "$field_def->{label} is required" } |
|
1012
|
5
|
50
|
|
|
|
24
|
if $field_def->{required}; # Stops input |
|
1013
|
5
|
|
|
|
|
18
|
next; # OK if value is null_value and not required, |
|
1014
|
|
|
|
|
|
|
# but no need to validate or input |
|
1015
|
|
|
|
|
|
|
} |
|
1016
|
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
# Get validator for this field |
|
1018
|
161
|
|
|
|
|
810
|
my $validator = $self->get_field_validator($field); |
|
1019
|
161
|
50
|
|
|
|
517
|
unless ($validator) { # No validator available, skip |
|
1020
|
0
|
|
|
|
|
0
|
push @warnings => "Validator not found for '$field'; input skipped"; |
|
1021
|
0
|
|
|
|
|
0
|
next; |
|
1022
|
|
|
|
|
|
|
} |
|
1023
|
|
|
|
|
|
|
|
|
1024
|
|
|
|
|
|
|
# Run validator |
|
1025
|
161
|
|
|
|
|
661
|
my $result = $validator->($user_data, $field, $field_def); |
|
1026
|
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
# Collect warnings |
|
1028
|
161
|
100
|
|
|
|
581
|
if ($result->{message}) { |
|
1029
|
10
|
|
|
|
|
37
|
push @warnings, "$field: $result->{message}"; |
|
1030
|
|
|
|
|
|
|
} |
|
1031
|
|
|
|
|
|
|
|
|
1032
|
|
|
|
|
|
|
# Only validated data will be returned |
|
1033
|
161
|
100
|
|
|
|
508
|
if ($result->{success}) { |
|
|
|
100
|
|
|
|
|
|
|
1034
|
151
|
|
|
|
|
866
|
$validated_data->{$field} = $value; |
|
1035
|
|
|
|
|
|
|
} |
|
1036
|
|
|
|
|
|
|
# Fail on validation errors only if must_validate is set for a field |
|
1037
|
|
|
|
|
|
|
elsif ($field_def->{must_validate}) { |
|
1038
|
4
|
|
|
|
|
34
|
return { success => 0, message => $result->{message}, field => $field }; |
|
1039
|
|
|
|
|
|
|
} |
|
1040
|
|
|
|
|
|
|
} |
|
1041
|
|
|
|
|
|
|
|
|
1042
|
|
|
|
|
|
|
# Return success with validated data and any warnings |
|
1043
|
133
|
|
|
|
|
559
|
my $outcome = { success => 1, valid_data => $validated_data }; |
|
1044
|
133
|
100
|
|
|
|
456
|
$outcome->{warnings} = \@warnings if @warnings; |
|
1045
|
133
|
|
|
|
|
507
|
return $outcome; |
|
1046
|
|
|
|
|
|
|
} |
|
1047
|
|
|
|
|
|
|
|
|
1048
|
|
|
|
|
|
|
# Parse filter DSL string into filter structure |
|
1049
|
|
|
|
|
|
|
sub parse_filter_string { |
|
1050
|
5
|
|
|
5
|
1
|
16
|
my ($self, $filter_string) = @_; |
|
1051
|
|
|
|
|
|
|
|
|
1052
|
5
|
|
|
|
|
40
|
my @or_groups = split /\s*\|\s*/, $filter_string; |
|
1053
|
5
|
|
|
|
|
13
|
my @parsed_filters; |
|
1054
|
|
|
|
|
|
|
|
|
1055
|
5
|
|
|
|
|
14
|
foreach my $group (@or_groups) { |
|
1056
|
5
|
|
|
|
|
15
|
my @and_conditions = split /\s*;\s*/, $group; |
|
1057
|
5
|
|
|
|
|
10
|
my @parsed_and; |
|
1058
|
|
|
|
|
|
|
|
|
1059
|
5
|
|
|
|
|
12
|
foreach my $condition (@and_conditions) { |
|
1060
|
|
|
|
|
|
|
# Parse [field][op][value] |
|
1061
|
5
|
50
|
|
|
|
41
|
if ($condition =~ /^(\w+)(=|:|!|>|<)(.+)$/) { |
|
1062
|
5
|
|
|
|
|
32
|
my ($field, $op, $value) = ($1, $2, $3); |
|
1063
|
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
# Validate field exists |
|
1065
|
5
|
50
|
|
|
|
11
|
unless (grep { $_ eq $field } @{$self->{fields}}) { |
|
|
44
|
|
|
|
|
100
|
|
|
|
5
|
|
|
|
|
19
|
|
|
1066
|
0
|
|
|
|
|
0
|
carp "Warning: Unknown field '$field' in filter"; |
|
1067
|
0
|
|
|
|
|
0
|
next; |
|
1068
|
|
|
|
|
|
|
} |
|
1069
|
|
|
|
|
|
|
|
|
1070
|
5
|
|
|
|
|
59
|
push @parsed_and, { |
|
1071
|
|
|
|
|
|
|
field => $field, |
|
1072
|
|
|
|
|
|
|
op => $op, |
|
1073
|
|
|
|
|
|
|
value => $value |
|
1074
|
|
|
|
|
|
|
}; |
|
1075
|
|
|
|
|
|
|
} else { |
|
1076
|
0
|
|
|
|
|
0
|
carp "Warning: Invalid filter condition '$condition'"; |
|
1077
|
|
|
|
|
|
|
} |
|
1078
|
|
|
|
|
|
|
} |
|
1079
|
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
# Only add non-empty AND groups |
|
1081
|
5
|
50
|
|
|
|
20
|
if (@parsed_and) { |
|
1082
|
5
|
|
|
|
|
20
|
push @parsed_filters, \@parsed_and; |
|
1083
|
|
|
|
|
|
|
} |
|
1084
|
|
|
|
|
|
|
} |
|
1085
|
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
# Return empty hash if no valid filters |
|
1087
|
5
|
50
|
|
|
|
18
|
return {} unless @parsed_filters; |
|
1088
|
|
|
|
|
|
|
|
|
1089
|
|
|
|
|
|
|
# Return structure for backend processing |
|
1090
|
|
|
|
|
|
|
return { |
|
1091
|
5
|
|
|
|
|
31
|
or_groups => \@parsed_filters, |
|
1092
|
|
|
|
|
|
|
raw => $filter_string |
|
1093
|
|
|
|
|
|
|
}; |
|
1094
|
|
|
|
|
|
|
} |
|
1095
|
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
1; |
|
1097
|
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
=head1 NAME |
|
1099
|
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
Concierge::Users::Meta - Field definitions, validators, and configuration |
|
1101
|
|
|
|
|
|
|
utilities for Concierge::Users |
|
1102
|
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
=head1 VERSION |
|
1104
|
|
|
|
|
|
|
|
|
1105
|
|
|
|
|
|
|
v0.7.4 |
|
1106
|
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
1108
|
|
|
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
use Concierge::Users; |
|
1110
|
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
my $users = Concierge::Users->new('/path/to/users-config.json'); |
|
1112
|
|
|
|
|
|
|
|
|
1113
|
|
|
|
|
|
|
# Introspect field schema |
|
1114
|
|
|
|
|
|
|
my $fields = $users->get_user_fields(); # ordered field list |
|
1115
|
|
|
|
|
|
|
my $def = $users->get_field_definition('email'); |
|
1116
|
|
|
|
|
|
|
my $hints = $users->get_field_hints('email'); |
|
1117
|
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
# Class-level field lists |
|
1119
|
|
|
|
|
|
|
my @core = Concierge::Users::Meta::user_core_fields(); |
|
1120
|
|
|
|
|
|
|
my @std = Concierge::Users::Meta::user_standard_fields(); |
|
1121
|
|
|
|
|
|
|
my @sys = Concierge::Users::Meta::user_system_fields(); |
|
1122
|
|
|
|
|
|
|
|
|
1123
|
|
|
|
|
|
|
# Display configuration |
|
1124
|
|
|
|
|
|
|
Concierge::Users::Meta->show_default_config(); # built-in defaults |
|
1125
|
|
|
|
|
|
|
$users->show_config(); # active setup |
|
1126
|
|
|
|
|
|
|
|
|
1127
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
1128
|
|
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
Concierge::Users::Meta is the parent class for L and all |
|
1130
|
|
|
|
|
|
|
storage backends. It owns the master field definitions, the validation |
|
1131
|
|
|
|
|
|
|
subsystem, the filter DSL parser, and the configuration display helpers. |
|
1132
|
|
|
|
|
|
|
Application code normally interacts with Meta indirectly through a |
|
1133
|
|
|
|
|
|
|
L instance, but the introspection methods and class-level |
|
1134
|
|
|
|
|
|
|
field lists are available for direct use. |
|
1135
|
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
=head1 FIELD CATALOG |
|
1137
|
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
Every user record is composed of fields drawn from three built-in |
|
1139
|
|
|
|
|
|
|
categories plus an optional application category. |
|
1140
|
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
=head2 Core Fields (4) |
|
1142
|
|
|
|
|
|
|
|
|
1143
|
|
|
|
|
|
|
Always present in every setup. |
|
1144
|
|
|
|
|
|
|
|
|
1145
|
|
|
|
|
|
|
=over 4 |
|
1146
|
|
|
|
|
|
|
|
|
1147
|
|
|
|
|
|
|
=item B |
|
1148
|
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
Primary authentication identifier. |
|
1150
|
|
|
|
|
|
|
|
|
1151
|
|
|
|
|
|
|
type: system |
|
1152
|
|
|
|
|
|
|
required: 1 |
|
1153
|
|
|
|
|
|
|
max_length: 30 |
|
1154
|
|
|
|
|
|
|
default: "" |
|
1155
|
|
|
|
|
|
|
null_value: "" |
|
1156
|
|
|
|
|
|
|
must_validate: 0 |
|
1157
|
|
|
|
|
|
|
description: User login ID - Primary authentication identifier |
|
1158
|
|
|
|
|
|
|
|
|
1159
|
|
|
|
|
|
|
=item B |
|
1160
|
|
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
User's preferred display name, nickname, or initials. |
|
1162
|
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
type: text |
|
1164
|
|
|
|
|
|
|
validate_as: moniker |
|
1165
|
|
|
|
|
|
|
required: 1 |
|
1166
|
|
|
|
|
|
|
max_length: 24 |
|
1167
|
|
|
|
|
|
|
default: "" |
|
1168
|
|
|
|
|
|
|
null_value: "" |
|
1169
|
|
|
|
|
|
|
must_validate: 1 |
|
1170
|
|
|
|
|
|
|
description: User's preferred display name, nickname, or initials |
|
1171
|
|
|
|
|
|
|
|
|
1172
|
|
|
|
|
|
|
=item B |
|
1173
|
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
Account status for access control. |
|
1175
|
|
|
|
|
|
|
|
|
1176
|
|
|
|
|
|
|
type: enum |
|
1177
|
|
|
|
|
|
|
validate_as: enum |
|
1178
|
|
|
|
|
|
|
required: 1 |
|
1179
|
|
|
|
|
|
|
options: *Eligible, OK, Inactive |
|
1180
|
|
|
|
|
|
|
max_length: 20 |
|
1181
|
|
|
|
|
|
|
default: Eligible (auto-set from * option) |
|
1182
|
|
|
|
|
|
|
null_value: "" |
|
1183
|
|
|
|
|
|
|
must_validate: 1 |
|
1184
|
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
This is a core field (always present), but its C can be |
|
1186
|
|
|
|
|
|
|
replaced via C to match your application's workflow. |
|
1187
|
|
|
|
|
|
|
See L for an example. |
|
1188
|
|
|
|
|
|
|
|
|
1189
|
|
|
|
|
|
|
=item B |
|
1190
|
|
|
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
Permission level for feature access. |
|
1192
|
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
type: enum |
|
1194
|
|
|
|
|
|
|
validate_as: enum |
|
1195
|
|
|
|
|
|
|
required: 1 |
|
1196
|
|
|
|
|
|
|
options: *anon, visitor, member, staff, admin |
|
1197
|
|
|
|
|
|
|
max_length: 20 |
|
1198
|
|
|
|
|
|
|
default: anon (auto-set from * option) |
|
1199
|
|
|
|
|
|
|
null_value: "" |
|
1200
|
|
|
|
|
|
|
must_validate: 1 |
|
1201
|
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
Core field (always present); C can be replaced via |
|
1203
|
|
|
|
|
|
|
C. See L. |
|
1204
|
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
=back |
|
1206
|
|
|
|
|
|
|
|
|
1207
|
|
|
|
|
|
|
=head2 Standard Fields (12) |
|
1208
|
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
Included by default when C is omitted or set |
|
1210
|
|
|
|
|
|
|
to C<'all'>. Pass an arrayref of names to select specific fields, or |
|
1211
|
|
|
|
|
|
|
an empty arrayref C<[]> to exclude all standard fields. |
|
1212
|
|
|
|
|
|
|
|
|
1213
|
|
|
|
|
|
|
B |
|
1214
|
|
|
|
|
|
|
|
|
1215
|
|
|
|
|
|
|
=over 4 |
|
1216
|
|
|
|
|
|
|
|
|
1217
|
|
|
|
|
|
|
=item B -- type C, validate_as C, max 50, must_validate 1 |
|
1218
|
|
|
|
|
|
|
|
|
1219
|
|
|
|
|
|
|
=item B -- type C, validate_as C, max 50, must_validate 1 |
|
1220
|
|
|
|
|
|
|
|
|
1221
|
|
|
|
|
|
|
=item B -- type C, validate_as C, max 50, must_validate 1 |
|
1222
|
|
|
|
|
|
|
|
|
1223
|
|
|
|
|
|
|
=item B -- type C, options: (none) Dr Mr Ms Mrs Mx Prof Hon Sir Madam, max 10 |
|
1224
|
|
|
|
|
|
|
|
|
1225
|
|
|
|
|
|
|
=item B -- type C, options: (none) Jr Sr II III IV V PhD MD DDS Esq, max 10 |
|
1226
|
|
|
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
=back |
|
1228
|
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
B |
|
1230
|
|
|
|
|
|
|
|
|
1231
|
|
|
|
|
|
|
=over 4 |
|
1232
|
|
|
|
|
|
|
|
|
1233
|
|
|
|
|
|
|
=item B -- type C, validate_as C, max 100 |
|
1234
|
|
|
|
|
|
|
|
|
1235
|
|
|
|
|
|
|
=item B -- type C, validate_as C, max 100 |
|
1236
|
|
|
|
|
|
|
|
|
1237
|
|
|
|
|
|
|
=back |
|
1238
|
|
|
|
|
|
|
|
|
1239
|
|
|
|
|
|
|
B |
|
1240
|
|
|
|
|
|
|
|
|
1241
|
|
|
|
|
|
|
=over 4 |
|
1242
|
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
=item B -- type C, validate_as C, max 255 |
|
1244
|
|
|
|
|
|
|
|
|
1245
|
|
|
|
|
|
|
=item B -- type C, validate_as C, max 20 |
|
1246
|
|
|
|
|
|
|
|
|
1247
|
|
|
|
|
|
|
=item B -- type C, validate_as C, null_value "", max 1 |
|
1248
|
|
|
|
|
|
|
|
|
1249
|
|
|
|
|
|
|
=back |
|
1250
|
|
|
|
|
|
|
|
|
1251
|
|
|
|
|
|
|
B |
|
1252
|
|
|
|
|
|
|
|
|
1253
|
|
|
|
|
|
|
=over 4 |
|
1254
|
|
|
|
|
|
|
|
|
1255
|
|
|
|
|
|
|
=item B -- type C, validate_as C, |
|
1256
|
|
|
|
|
|
|
default C<0000-00-00 00:00:00>, max 19 |
|
1257
|
|
|
|
|
|
|
|
|
1258
|
|
|
|
|
|
|
=item B -- type C, validate_as C, |
|
1259
|
|
|
|
|
|
|
null_value C<0000-00-00>, max 10 |
|
1260
|
|
|
|
|
|
|
|
|
1261
|
|
|
|
|
|
|
=back |
|
1262
|
|
|
|
|
|
|
|
|
1263
|
|
|
|
|
|
|
All standard fields have C 0> by default. |
|
1264
|
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
=head2 System Fields (2) |
|
1266
|
|
|
|
|
|
|
|
|
1267
|
|
|
|
|
|
|
Always appended to the field list. Auto-managed by the backends; |
|
1268
|
|
|
|
|
|
|
cannot be set through the public API. Protected from overrides. |
|
1269
|
|
|
|
|
|
|
|
|
1270
|
|
|
|
|
|
|
=over 4 |
|
1271
|
|
|
|
|
|
|
|
|
1272
|
|
|
|
|
|
|
=item B -- type C, timestamp updated on every write |
|
1273
|
|
|
|
|
|
|
|
|
1274
|
|
|
|
|
|
|
=item B -- type C, timestamp set once on creation, |
|
1275
|
|
|
|
|
|
|
C 1> |
|
1276
|
|
|
|
|
|
|
|
|
1277
|
|
|
|
|
|
|
=back |
|
1278
|
|
|
|
|
|
|
|
|
1279
|
|
|
|
|
|
|
=head1 FIELD ATTRIBUTES |
|
1280
|
|
|
|
|
|
|
|
|
1281
|
|
|
|
|
|
|
Each field definition is a hashref that may contain the following keys: |
|
1282
|
|
|
|
|
|
|
|
|
1283
|
|
|
|
|
|
|
=over 4 |
|
1284
|
|
|
|
|
|
|
|
|
1285
|
|
|
|
|
|
|
=item C -- Internal name (snake_case). Used as hash key and |
|
1286
|
|
|
|
|
|
|
column/file identifier. |
|
1287
|
|
|
|
|
|
|
|
|
1288
|
|
|
|
|
|
|
=item C -- One of C, C, C, or C. |
|
1289
|
|
|
|
|
|
|
Set automatically; protected from overrides. |
|
1290
|
|
|
|
|
|
|
|
|
1291
|
|
|
|
|
|
|
=item C -- Data type: C, C, C, C, |
|
1292
|
|
|
|
|
|
|
C, C, C, C, C. |
|
1293
|
|
|
|
|
|
|
|
|
1294
|
|
|
|
|
|
|
=item C -- Validator to use if different from C. |
|
1295
|
|
|
|
|
|
|
See L. |
|
1296
|
|
|
|
|
|
|
|
|
1297
|
|
|
|
|
|
|
=item C |
|
1298
|
|
|
|
|
|
|
from C if omitted. |
|
1299
|
|
|
|
|
|
|
|
|
1300
|
|
|
|
|
|
|
=item C -- Short explanatory text for documentation or UI |
|
1301
|
|
|
|
|
|
|
hints. |
|
1302
|
|
|
|
|
|
|
|
|
1303
|
|
|
|
|
|
|
=item C -- C<1> if the field must have a non-null value on |
|
1304
|
|
|
|
|
|
|
creation; C<0> otherwise. |
|
1305
|
|
|
|
|
|
|
|
|
1306
|
|
|
|
|
|
|
=item C -- C<1> if a validation failure should reject the |
|
1307
|
|
|
|
|
|
|
entire operation; C<0> to treat failure as a non-fatal warning. |
|
1308
|
|
|
|
|
|
|
|
|
1309
|
|
|
|
|
|
|
=item C -- Arrayref of allowed values for C fields. |
|
1310
|
|
|
|
|
|
|
Prefix one option with C<*> to designate the default (see |
|
1311
|
|
|
|
|
|
|
L). |
|
1312
|
|
|
|
|
|
|
|
|
1313
|
|
|
|
|
|
|
=item C -- Value assigned to the field on new-record creation |
|
1314
|
|
|
|
|
|
|
when no value is supplied. |
|
1315
|
|
|
|
|
|
|
|
|
1316
|
|
|
|
|
|
|
=item C -- Sentinel that represents "no data" for this field |
|
1317
|
|
|
|
|
|
|
type (e.g. C<""> for text, C<""> for boolean, C<0000-00-00> for date). |
|
1318
|
|
|
|
|
|
|
|
|
1319
|
|
|
|
|
|
|
=item C -- Maximum character length enforced by the C |
|
1320
|
|
|
|
|
|
|
validator and used as a UI hint. |
|
1321
|
|
|
|
|
|
|
|
|
1322
|
|
|
|
|
|
|
=back |
|
1323
|
|
|
|
|
|
|
|
|
1324
|
|
|
|
|
|
|
=head1 VALIDATOR TYPES |
|
1325
|
|
|
|
|
|
|
|
|
1326
|
|
|
|
|
|
|
Ten built-in validators are available. Each is selected by the field's |
|
1327
|
|
|
|
|
|
|
C (or C as fallback) and receives |
|
1328
|
|
|
|
|
|
|
C<($user_data, $field_name, $field_def)>. |
|
1329
|
|
|
|
|
|
|
|
|
1330
|
|
|
|
|
|
|
=over 4 |
|
1331
|
|
|
|
|
|
|
|
|
1332
|
|
|
|
|
|
|
=item B |
|
1333
|
|
|
|
|
|
|
|
|
1334
|
|
|
|
|
|
|
Validates C if defined. Accepts any string. |
|
1335
|
|
|
|
|
|
|
|
|
1336
|
|
|
|
|
|
|
null_value: "" |
|
1337
|
|
|
|
|
|
|
|
|
1338
|
|
|
|
|
|
|
=item B |
|
1339
|
|
|
|
|
|
|
|
|
1340
|
|
|
|
|
|
|
Pattern: C<< /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ >> |
|
1341
|
|
|
|
|
|
|
|
|
1342
|
|
|
|
|
|
|
null_value: "" |
|
1343
|
|
|
|
|
|
|
|
|
1344
|
|
|
|
|
|
|
=item B |
|
1345
|
|
|
|
|
|
|
|
|
1346
|
|
|
|
|
|
|
Digits, spaces, hyphens, parentheses, optional leading C<+>; |
|
1347
|
|
|
|
|
|
|
minimum 7 characters. |
|
1348
|
|
|
|
|
|
|
|
|
1349
|
|
|
|
|
|
|
null_value: "" |
|
1350
|
|
|
|
|
|
|
|
|
1351
|
|
|
|
|
|
|
=item B |
|
1352
|
|
|
|
|
|
|
|
|
1353
|
|
|
|
|
|
|
Pattern: C (C<< /^\d{4}-\d{2}-\d{2}$/ >>). |
|
1354
|
|
|
|
|
|
|
|
|
1355
|
|
|
|
|
|
|
null_value: "0000-00-00" |
|
1356
|
|
|
|
|
|
|
|
|
1357
|
|
|
|
|
|
|
=item B |
|
1358
|
|
|
|
|
|
|
|
|
1359
|
|
|
|
|
|
|
Pattern: C or C. |
|
1360
|
|
|
|
|
|
|
|
|
1361
|
|
|
|
|
|
|
null_value: "0000-00-00 00:00:00" |
|
1362
|
|
|
|
|
|
|
|
|
1363
|
|
|
|
|
|
|
=item B |
|
1364
|
|
|
|
|
|
|
|
|
1365
|
|
|
|
|
|
|
Strictly C<0> or C<1>. |
|
1366
|
|
|
|
|
|
|
|
|
1367
|
|
|
|
|
|
|
null_value: "" |
|
1368
|
|
|
|
|
|
|
|
|
1369
|
|
|
|
|
|
|
=item B |
|
1370
|
|
|
|
|
|
|
|
|
1371
|
|
|
|
|
|
|
Optional leading minus, digits only (C<< /^\-?\d+$/ >>). |
|
1372
|
|
|
|
|
|
|
|
|
1373
|
|
|
|
|
|
|
null_value: "" |
|
1374
|
|
|
|
|
|
|
|
|
1375
|
|
|
|
|
|
|
=item B |
|
1376
|
|
|
|
|
|
|
|
|
1377
|
|
|
|
|
|
|
Value must appear in the field's C list (options with C<*> |
|
1378
|
|
|
|
|
|
|
prefix stripped). |
|
1379
|
|
|
|
|
|
|
|
|
1380
|
|
|
|
|
|
|
null_value: "" |
|
1381
|
|
|
|
|
|
|
|
|
1382
|
|
|
|
|
|
|
=item B |
|
1383
|
|
|
|
|
|
|
|
|
1384
|
|
|
|
|
|
|
2-24 alphanumeric characters, no spaces |
|
1385
|
|
|
|
|
|
|
(C<< /^[a-zA-Z0-9]{2,24}$/ >>). |
|
1386
|
|
|
|
|
|
|
|
|
1387
|
|
|
|
|
|
|
null_value: "" |
|
1388
|
|
|
|
|
|
|
|
|
1389
|
|
|
|
|
|
|
=item B |
|
1390
|
|
|
|
|
|
|
|
|
1391
|
|
|
|
|
|
|
Letters (including accented), hyphens, apostrophes, and internal |
|
1392
|
|
|
|
|
|
|
spaces. |
|
1393
|
|
|
|
|
|
|
|
|
1394
|
|
|
|
|
|
|
null_value: "" |
|
1395
|
|
|
|
|
|
|
|
|
1396
|
|
|
|
|
|
|
=back |
|
1397
|
|
|
|
|
|
|
|
|
1398
|
|
|
|
|
|
|
=head2 validate_as vs type |
|
1399
|
|
|
|
|
|
|
|
|
1400
|
|
|
|
|
|
|
A field's C declares its data type and determines the default |
|
1401
|
|
|
|
|
|
|
validator. C overrides the validator without changing |
|
1402
|
|
|
|
|
|
|
the type. For example, an application field with C<< type => 'text' >> |
|
1403
|
|
|
|
|
|
|
and C<< validate_as => 'moniker' >> is stored as text but validated with |
|
1404
|
|
|
|
|
|
|
the moniker pattern. When C is changed via a field override and |
|
1405
|
|
|
|
|
|
|
C is not explicitly set, C is updated |
|
1406
|
|
|
|
|
|
|
automatically to match the new type. |
|
1407
|
|
|
|
|
|
|
|
|
1408
|
|
|
|
|
|
|
=head2 must_validate Behavior |
|
1409
|
|
|
|
|
|
|
|
|
1410
|
|
|
|
|
|
|
When C is C<1> for a field, a validation failure causes |
|
1411
|
|
|
|
|
|
|
the entire C or C call to return |
|
1412
|
|
|
|
|
|
|
C<< { success => 0 } >>. When C is C<0>, the field's |
|
1413
|
|
|
|
|
|
|
value is silently dropped and a warning is appended to the response. |
|
1414
|
|
|
|
|
|
|
|
|
1415
|
|
|
|
|
|
|
Setting C<< required => 1 >> in a field override automatically enables |
|
1416
|
|
|
|
|
|
|
C unless C is explicitly set in the same |
|
1417
|
|
|
|
|
|
|
override. |
|
1418
|
|
|
|
|
|
|
|
|
1419
|
|
|
|
|
|
|
The environment variable C bypasses all |
|
1420
|
|
|
|
|
|
|
validation when set to a true value. |
|
1421
|
|
|
|
|
|
|
|
|
1422
|
|
|
|
|
|
|
=head1 FIELD CUSTOMIZATION |
|
1423
|
|
|
|
|
|
|
|
|
1424
|
|
|
|
|
|
|
=head2 Application Fields |
|
1425
|
|
|
|
|
|
|
|
|
1426
|
|
|
|
|
|
|
Pass C to C<< Concierge::Users->setup() >> as an arrayref. |
|
1427
|
|
|
|
|
|
|
Each element is either a string (minimal definition) or a hashref (full |
|
1428
|
|
|
|
|
|
|
definition): |
|
1429
|
|
|
|
|
|
|
|
|
1430
|
|
|
|
|
|
|
app_fields => [ |
|
1431
|
|
|
|
|
|
|
'nickname', # string shorthand |
|
1432
|
|
|
|
|
|
|
{ # full definition |
|
1433
|
|
|
|
|
|
|
field_name => 'department', |
|
1434
|
|
|
|
|
|
|
type => 'enum', |
|
1435
|
|
|
|
|
|
|
options => ['*Engineering', 'Sales', 'Support'], |
|
1436
|
|
|
|
|
|
|
required => 1, |
|
1437
|
|
|
|
|
|
|
label => 'Department', |
|
1438
|
|
|
|
|
|
|
}, |
|
1439
|
|
|
|
|
|
|
], |
|
1440
|
|
|
|
|
|
|
|
|
1441
|
|
|
|
|
|
|
String shorthand creates a field with C<< type => 'text' >>, |
|
1442
|
|
|
|
|
|
|
C<< validate_as => 'text' >>, C<< required => 0 >>. |
|
1443
|
|
|
|
|
|
|
|
|
1444
|
|
|
|
|
|
|
Reserved names (any core, standard, or system field name) are rejected |
|
1445
|
|
|
|
|
|
|
with a warning. |
|
1446
|
|
|
|
|
|
|
|
|
1447
|
|
|
|
|
|
|
=head2 Field Overrides |
|
1448
|
|
|
|
|
|
|
|
|
1449
|
|
|
|
|
|
|
Pass C to C as an arrayref of hashrefs. |
|
1450
|
|
|
|
|
|
|
Each must contain C to identify the target: |
|
1451
|
|
|
|
|
|
|
|
|
1452
|
|
|
|
|
|
|
field_overrides => [ |
|
1453
|
|
|
|
|
|
|
{ |
|
1454
|
|
|
|
|
|
|
field_name => 'email', |
|
1455
|
|
|
|
|
|
|
required => 1, |
|
1456
|
|
|
|
|
|
|
label => 'Work Email', |
|
1457
|
|
|
|
|
|
|
}, |
|
1458
|
|
|
|
|
|
|
], |
|
1459
|
|
|
|
|
|
|
|
|
1460
|
|
|
|
|
|
|
B that cannot be overridden: C, |
|
1461
|
|
|
|
|
|
|
C, C. |
|
1462
|
|
|
|
|
|
|
|
|
1463
|
|
|
|
|
|
|
B that cannot be changed: C, |
|
1464
|
|
|
|
|
|
|
C. |
|
1465
|
|
|
|
|
|
|
|
|
1466
|
|
|
|
|
|
|
Auto-behaviors: |
|
1467
|
|
|
|
|
|
|
|
|
1468
|
|
|
|
|
|
|
=over 4 |
|
1469
|
|
|
|
|
|
|
|
|
1470
|
|
|
|
|
|
|
=item * Changing C auto-updates C to match (unless |
|
1471
|
|
|
|
|
|
|
C is also specified). |
|
1472
|
|
|
|
|
|
|
|
|
1473
|
|
|
|
|
|
|
=item * Setting C<< required => 1 >> auto-enables C |
|
1474
|
|
|
|
|
|
|
(unless C is also specified). |
|
1475
|
|
|
|
|
|
|
|
|
1476
|
|
|
|
|
|
|
=item * An unknown C value falls back to C with a |
|
1477
|
|
|
|
|
|
|
warning. |
|
1478
|
|
|
|
|
|
|
|
|
1479
|
|
|
|
|
|
|
=back |
|
1480
|
|
|
|
|
|
|
|
|
1481
|
|
|
|
|
|
|
B Core fields like C and |
|
1482
|
|
|
|
|
|
|
C are always present, but their C are not |
|
1483
|
|
|
|
|
|
|
fixed. Replace them with values that fit your domain: |
|
1484
|
|
|
|
|
|
|
|
|
1485
|
|
|
|
|
|
|
# Makerspace member status instead of the default |
|
1486
|
|
|
|
|
|
|
# Eligible / OK / Inactive |
|
1487
|
|
|
|
|
|
|
field_overrides => [ |
|
1488
|
|
|
|
|
|
|
{ |
|
1489
|
|
|
|
|
|
|
field_name => 'user_status', |
|
1490
|
|
|
|
|
|
|
options => [qw( *Applicant Novice Skilled |
|
1491
|
|
|
|
|
|
|
Expert Mentor Steward )], |
|
1492
|
|
|
|
|
|
|
}, |
|
1493
|
|
|
|
|
|
|
], |
|
1494
|
|
|
|
|
|
|
|
|
1495
|
|
|
|
|
|
|
The C<*>-prefixed option becomes the default (see L
|
|
1496
|
|
|
|
|
|
|
Convention>). Validation, filtering, and all other enum behaviors |
|
1497
|
|
|
|
|
|
|
apply to the new option set automatically. |
|
1498
|
|
|
|
|
|
|
|
|
1499
|
|
|
|
|
|
|
=head2 Enum Default Convention |
|
1500
|
|
|
|
|
|
|
|
|
1501
|
|
|
|
|
|
|
In an C arrayref, prefix exactly one value with C<*> to mark it |
|
1502
|
|
|
|
|
|
|
as the default: |
|
1503
|
|
|
|
|
|
|
|
|
1504
|
|
|
|
|
|
|
options => ['*Free', 'Premium', 'Enterprise'] |
|
1505
|
|
|
|
|
|
|
|
|
1506
|
|
|
|
|
|
|
The C<*> is stripped for validation (stored internally in C). |
|
1507
|
|
|
|
|
|
|
If no explicit C is set for the field, the C<*>-marked option |
|
1508
|
|
|
|
|
|
|
becomes the default automatically. A bare C<*> (e.g. in C and |
|
1509
|
|
|
|
|
|
|
C) represents an empty default. |
|
1510
|
|
|
|
|
|
|
|
|
1511
|
|
|
|
|
|
|
=head1 FILTER DSL |
|
1512
|
|
|
|
|
|
|
|
|
1513
|
|
|
|
|
|
|
The C method accepts a filter string with five operators and |
|
1514
|
|
|
|
|
|
|
two combinators. |
|
1515
|
|
|
|
|
|
|
|
|
1516
|
|
|
|
|
|
|
=head2 Operators |
|
1517
|
|
|
|
|
|
|
|
|
1518
|
|
|
|
|
|
|
= exact match user_status=OK |
|
1519
|
|
|
|
|
|
|
: substring (case-insensitive) last_name:smith |
|
1520
|
|
|
|
|
|
|
! not-contains (case-insensitive) email!example.org |
|
1521
|
|
|
|
|
|
|
> greater than (string) last_login_date>2025-01-01 |
|
1522
|
|
|
|
|
|
|
< less than (string) term_ends<2026-01-01 |
|
1523
|
|
|
|
|
|
|
|
|
1524
|
|
|
|
|
|
|
=head2 Combinators |
|
1525
|
|
|
|
|
|
|
|
|
1526
|
|
|
|
|
|
|
; AND -- all conditions must match |
|
1527
|
|
|
|
|
|
|
| OR -- at least one group must match |
|
1528
|
|
|
|
|
|
|
|
|
1529
|
|
|
|
|
|
|
AND binds tighter than OR: C means |
|
1530
|
|
|
|
|
|
|
C<(a=1 AND b=2) OR (c=3)>. |
|
1531
|
|
|
|
|
|
|
|
|
1532
|
|
|
|
|
|
|
=head2 Examples |
|
1533
|
|
|
|
|
|
|
|
|
1534
|
|
|
|
|
|
|
# Active members |
|
1535
|
|
|
|
|
|
|
user_status=OK;access_level=member |
|
1536
|
|
|
|
|
|
|
|
|
1537
|
|
|
|
|
|
|
# Staff or admin |
|
1538
|
|
|
|
|
|
|
access_level=staff|access_level=admin |
|
1539
|
|
|
|
|
|
|
|
|
1540
|
|
|
|
|
|
|
# Name search with status filter |
|
1541
|
|
|
|
|
|
|
last_name:Garcia;user_status=OK |
|
1542
|
|
|
|
|
|
|
|
|
1543
|
|
|
|
|
|
|
# Recent logins |
|
1544
|
|
|
|
|
|
|
last_login_date>2025-06-01 |
|
1545
|
|
|
|
|
|
|
|
|
1546
|
|
|
|
|
|
|
Unknown fields in a filter string produce a warning and are skipped. |
|
1547
|
|
|
|
|
|
|
|
|
1548
|
|
|
|
|
|
|
=head1 METHODS |
|
1549
|
|
|
|
|
|
|
|
|
1550
|
|
|
|
|
|
|
=head2 Class Methods |
|
1551
|
|
|
|
|
|
|
|
|
1552
|
|
|
|
|
|
|
=head3 user_core_fields |
|
1553
|
|
|
|
|
|
|
|
|
1554
|
|
|
|
|
|
|
my @fields = Concierge::Users::Meta::user_core_fields(); |
|
1555
|
|
|
|
|
|
|
|
|
1556
|
|
|
|
|
|
|
Returns the list of core field names: |
|
1557
|
|
|
|
|
|
|
C, C, C, C. |
|
1558
|
|
|
|
|
|
|
|
|
1559
|
|
|
|
|
|
|
=head3 user_standard_fields |
|
1560
|
|
|
|
|
|
|
|
|
1561
|
|
|
|
|
|
|
my @fields = Concierge::Users::Meta::user_standard_fields(); |
|
1562
|
|
|
|
|
|
|
|
|
1563
|
|
|
|
|
|
|
Returns the list of standard field names (12 fields). |
|
1564
|
|
|
|
|
|
|
|
|
1565
|
|
|
|
|
|
|
=head3 user_system_fields |
|
1566
|
|
|
|
|
|
|
|
|
1567
|
|
|
|
|
|
|
my @fields = Concierge::Users::Meta::user_system_fields(); |
|
1568
|
|
|
|
|
|
|
|
|
1569
|
|
|
|
|
|
|
Returns the list of system field names: C, |
|
1570
|
|
|
|
|
|
|
C. |
|
1571
|
|
|
|
|
|
|
|
|
1572
|
|
|
|
|
|
|
=head3 init_field_meta |
|
1573
|
|
|
|
|
|
|
|
|
1574
|
|
|
|
|
|
|
my $meta = Concierge::Users::Meta::init_field_meta(\%config); |
|
1575
|
|
|
|
|
|
|
|
|
1576
|
|
|
|
|
|
|
Processes the setup configuration and returns a hashref with C |
|
1577
|
|
|
|
|
|
|
(ordered arrayref) and C (hashref of field |
|
1578
|
|
|
|
|
|
|
definitions). Called internally by C<< Concierge::Users->setup() >>. |
|
1579
|
|
|
|
|
|
|
|
|
1580
|
|
|
|
|
|
|
=head3 show_default_config |
|
1581
|
|
|
|
|
|
|
|
|
1582
|
|
|
|
|
|
|
Concierge::Users::Meta->show_default_config(); |
|
1583
|
|
|
|
|
|
|
|
|
1584
|
|
|
|
|
|
|
Prints the built-in default field configuration template to STDOUT. |
|
1585
|
|
|
|
|
|
|
|
|
1586
|
|
|
|
|
|
|
=head2 Instance Methods |
|
1587
|
|
|
|
|
|
|
|
|
1588
|
|
|
|
|
|
|
=head3 get_field_definition |
|
1589
|
|
|
|
|
|
|
|
|
1590
|
|
|
|
|
|
|
my $def = $users->get_field_definition('email'); |
|
1591
|
|
|
|
|
|
|
|
|
1592
|
|
|
|
|
|
|
Returns the complete field definition hashref for the named field, or |
|
1593
|
|
|
|
|
|
|
C if the field is not in the current schema. |
|
1594
|
|
|
|
|
|
|
|
|
1595
|
|
|
|
|
|
|
=head3 get_field_validator |
|
1596
|
|
|
|
|
|
|
|
|
1597
|
|
|
|
|
|
|
my $code_ref = $users->get_field_validator('email'); |
|
1598
|
|
|
|
|
|
|
|
|
1599
|
|
|
|
|
|
|
Returns the validator code reference for the named field based on its |
|
1600
|
|
|
|
|
|
|
C or C, or C if no validator is available. |
|
1601
|
|
|
|
|
|
|
|
|
1602
|
|
|
|
|
|
|
=head3 get_field_hints |
|
1603
|
|
|
|
|
|
|
|
|
1604
|
|
|
|
|
|
|
my $hints = $users->get_field_hints('email'); |
|
1605
|
|
|
|
|
|
|
|
|
1606
|
|
|
|
|
|
|
Returns a hashref of UI-friendly attributes: C |
|
1607
|
|
|
|
|
|
|
C, C, C, C. |
|
1608
|
|
|
|
|
|
|
|
|
1609
|
|
|
|
|
|
|
=head3 get_user_fields |
|
1610
|
|
|
|
|
|
|
|
|
1611
|
|
|
|
|
|
|
my $fields = $users->get_user_fields(); |
|
1612
|
|
|
|
|
|
|
|
|
1613
|
|
|
|
|
|
|
Returns the ordered arrayref of field names for this instance's schema. |
|
1614
|
|
|
|
|
|
|
|
|
1615
|
|
|
|
|
|
|
=head3 validate_user_data |
|
1616
|
|
|
|
|
|
|
|
|
1617
|
|
|
|
|
|
|
my $result = $users->validate_user_data(\%data); |
|
1618
|
|
|
|
|
|
|
|
|
1619
|
|
|
|
|
|
|
Validates C<%data> against the field schema. Returns |
|
1620
|
|
|
|
|
|
|
C<< { success => 1, valid_data => \%clean } >> on success (with optional |
|
1621
|
|
|
|
|
|
|
C arrayref), or C<< { success => 0, message => $reason } >> |
|
1622
|
|
|
|
|
|
|
on failure. |
|
1623
|
|
|
|
|
|
|
|
|
1624
|
|
|
|
|
|
|
=head3 parse_filter_string |
|
1625
|
|
|
|
|
|
|
|
|
1626
|
|
|
|
|
|
|
my $filters = $users->parse_filter_string('user_status=OK;access_level=member'); |
|
1627
|
|
|
|
|
|
|
|
|
1628
|
|
|
|
|
|
|
Parses a filter DSL string into an internal structure suitable for |
|
1629
|
|
|
|
|
|
|
backend list methods. See L. |
|
1630
|
|
|
|
|
|
|
|
|
1631
|
|
|
|
|
|
|
=head3 show_config |
|
1632
|
|
|
|
|
|
|
|
|
1633
|
|
|
|
|
|
|
$users->show_config(); |
|
1634
|
|
|
|
|
|
|
$users->show_config(output_path => '/tmp/config.yaml'); |
|
1635
|
|
|
|
|
|
|
|
|
1636
|
|
|
|
|
|
|
Prints the active YAML configuration file for this instance to STDOUT. |
|
1637
|
|
|
|
|
|
|
Must be called on a L instance (not a class method). |
|
1638
|
|
|
|
|
|
|
|
|
1639
|
|
|
|
|
|
|
=head3 config_to_yaml |
|
1640
|
|
|
|
|
|
|
|
|
1641
|
|
|
|
|
|
|
my $yaml = Concierge::Users::Meta::config_to_yaml(\%config, $storage_dir); |
|
1642
|
|
|
|
|
|
|
|
|
1643
|
|
|
|
|
|
|
Converts a configuration hashref to a human-readable YAML string with a |
|
1644
|
|
|
|
|
|
|
warning header. Used internally during C. |
|
1645
|
|
|
|
|
|
|
|
|
1646
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
1647
|
|
|
|
|
|
|
|
|
1648
|
|
|
|
|
|
|
L -- main API and CRUD operations |
|
1649
|
|
|
|
|
|
|
|
|
1650
|
|
|
|
|
|
|
L, L, |
|
1651
|
|
|
|
|
|
|
L -- storage backend implementations |
|
1652
|
|
|
|
|
|
|
|
|
1653
|
|
|
|
|
|
|
=head1 AUTHOR |
|
1654
|
|
|
|
|
|
|
|
|
1655
|
|
|
|
|
|
|
Bruce Van Allen |
|
1656
|
|
|
|
|
|
|
|
|
1657
|
|
|
|
|
|
|
=head1 LICENSE |
|
1658
|
|
|
|
|
|
|
|
|
1659
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
|
1660
|
|
|
|
|
|
|
under the terms of the Artistic License 2.0. |
|
1661
|
|
|
|
|
|
|
|
|
1662
|
|
|
|
|
|
|
=cut |
|
1663
|
|
|
|
|
|
|
|
|
1664
|
|
|
|
|
|
|
__DATA__ |