Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16766 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15398 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\DiscoveryContact;
6
 
7
use Laminas\InputFilter\InputFilter;
8
use Laminas\Db\Adapter\Adapter;
9
use LeadersLinked\Mapper\DiscoveryContactMapper;
10
 
11
class ContactFilter extends InputFilter
12
{
13
 
14
    /**
15
     *
16
     * @param Adapter $adapter
17
     * @param int $company_id
18
     * @param int $exclude_id
19
     */
20
    public function __construct($adapter, $company_id, $exclude_id)
21
    {
22
        $this->add([
23
            'name' => 'first_name',
24
            'required' => true,
25
            'filters' => [
26
                ['name' => \Laminas\Filter\StripTags::class],
27
                ['name' => \Laminas\Filter\StringTrim::class],
28
            ],
29
            'validators' => [
30
                [
31
                    'name' => \Laminas\Validator\StringLength::class,
32
                    'options' => [
33
                        'encoding' => 'UTF-8',
34
                        'max' => 128,
35
                    ],
36
                ],
37
                [
38
                    'name' => \Laminas\Validator\NotEmpty::class,
39
                ],
40
            ],
41
        ]);
42
 
43
        $this->add([
44
            'name' => 'last_name',
45
            'required' => true,
46
            'filters' => [
47
                ['name' => \Laminas\Filter\StripTags::class],
48
                ['name' => \Laminas\Filter\StringTrim::class],
49
            ],
50
            'validators' => [
51
                [
52
                    'name' => \Laminas\Validator\StringLength::class,
53
                    'options' => [
54
                        'encoding' => 'UTF-8',
55
                        'max' => 128,
56
                    ],
57
                ],
58
                [
59
                    'name' => \Laminas\Validator\NotEmpty::class,
60
                ],
61
            ],
62
        ]);
63
 
64
        $this->add([
65
            'name' => 'corporate_email',
66
            'required' => true,
67
            'filters' => [
68
                ['name' => \Laminas\Filter\StripTags::class],
69
                ['name' => \Laminas\Filter\StringTrim::class],
70
            ],
71
            'validators' => [
72
                [
73
                    'name' => \Laminas\Validator\StringLength::class,
74
                    'options' => [
75
                        'encoding' => 'UTF-8',
76
                        'max' => 250,
77
                    ],
78
                ],
79
                [
80
                    'name' => \Laminas\Validator\NotEmpty::class,
81
                ],
82
                [
17002 efrain 83
                    'name' => \Laminas\Validator\EmailAddress::class,
84
                ],
85
                [
15398 efrain 86
                    'name' => \LeadersLinked\Validator\NoRecordExistsMultiFields::class,
87
                    'options' => [
88
                        'adapter' => $adapter,
89
                        'table' => DiscoveryContactMapper::_TABLE,
90
                        'field' => 'corporate_email',
91
                        'exclude' => [
92
                            'field' => 'id',
93
                            'value' => $exclude_id
94
 
95
                        ],
96
                        'custom_fields' => [
97
                            'company_id' => $company_id,
98
                        ]
99
                    ]
100
                ]
101
            ],
102
        ]);
103
 
104
        $this->add([
105
            'name' => 'company',
106
            'required' => true,
107
            'filters' => [
108
                ['name' => \Laminas\Filter\StripTags::class],
109
                ['name' => \Laminas\Filter\StringTrim::class],
110
            ],
111
            'validators' => [
112
                [
113
                    'name' => \Laminas\Validator\StringLength::class,
114
                    'options' => [
115
                        'encoding' => 'UTF-8',
116
                        'max' => 128,
117
                    ],
118
                ],
119
                [
120
                    'name' => \Laminas\Validator\NotEmpty::class,
121
                ],
122
            ],
123
        ]);
124
 
125
        $this->add([
126
            'name' => 'position',
127
            'required' => true,
128
            'filters' => [
129
                ['name' => \Laminas\Filter\StripTags::class],
130
                ['name' => \Laminas\Filter\StringTrim::class],
131
            ],
132
            'validators' => [
133
                [
134
                    'name' => \Laminas\Validator\StringLength::class,
135
                    'options' => [
136
                        'encoding' => 'UTF-8',
137
                        'max' => 128,
138
                    ],
139
                ],
140
                [
141
                    'name' => \Laminas\Validator\NotEmpty::class,
142
                ],
143
            ],
144
        ]);
145
 
146
        $this->add([
147
            'name' => 'country',
148
            'required' => true,
149
            'filters' => [
150
                ['name' => \Laminas\Filter\StripTags::class],
151
                ['name' => \Laminas\Filter\StringTrim::class],
152
            ],
153
            'validators' => [
154
                [
155
                    'name' => \Laminas\Validator\StringLength::class,
156
                    'options' => [
157
                        'encoding' => 'UTF-8',
158
                        'max' => 128,
159
                    ],
160
                ],
161
                [
162
                    'name' => \Laminas\Validator\NotEmpty::class,
163
                ],
164
            ],
165
        ]);
166
 
167
        $this->add([
168
            'name' => 'state',
169
            'required' => false,
170
            'filters' => [
171
                ['name' => \Laminas\Filter\StripTags::class],
172
                ['name' => \Laminas\Filter\StringTrim::class],
173
            ],
174
            'validators' => [
175
                [
176
                    'name' => \Laminas\Validator\StringLength::class,
177
                    'options' => [
178
                        'encoding' => 'UTF-8',
179
                        'max' => 128,
180
                    ],
181
                ],
182
                [
183
                    'name' => \Laminas\Validator\NotEmpty::class,
184
                ],
185
            ],
186
        ]);
187
 
188
        $this->add([
189
            'name' => 'city',
190
            'required' => false,
191
            'filters' => [
192
                ['name' => \Laminas\Filter\StripTags::class],
193
                ['name' => \Laminas\Filter\StringTrim::class],
194
            ],
195
            'validators' => [
196
                [
197
                    'name' => \Laminas\Validator\StringLength::class,
198
                    'options' => [
199
                        'encoding' => 'UTF-8',
200
                        'max' => 128,
201
                    ],
202
                ],
203
                [
204
                    'name' => \Laminas\Validator\NotEmpty::class,
205
                ],
206
            ],
207
        ]);
208
 
209
 
210
        $this->add([
211
            'name' => 'personal_email',
212
            'required' => false,
213
            'filters' => [
214
                ['name' => \Laminas\Filter\StripTags::class],
215
                ['name' => \Laminas\Filter\StringTrim::class],
216
            ],
217
            'validators' => [
218
                [
219
                    'name' => \Laminas\Validator\StringLength::class,
220
                    'options' => [
221
                        'encoding' => 'UTF-8',
222
                        'max' => 250,
223
                    ],
224
                ],
225
                [
226
                    'name' => \Laminas\Validator\NotEmpty::class,
227
                ],
228
                [
17002 efrain 229
                    'name' => \Laminas\Validator\EmailAddress::class,
230
                ],
231
                [
15398 efrain 232
                    'name' => \LeadersLinked\Validator\NoRecordExistsMultiFields::class,
233
                    'options' => [
234
                        'adapter' => $adapter,
235
                        'table' => DiscoveryContactMapper::_TABLE,
236
                        'field' => 'personal_email',
237
                        'exclude' => [
238
                            'field' => 'id',
239
                            'value' => $exclude_id
240
 
241
                        ],
242
                        'custom_fields' => [
243
                            'company_id' => $company_id,
244
                        ]
245
                    ]
246
                ]
247
            ],
248
        ]);
249
 
250
        $this->add([
251
            'name' => 'phone',
252
            'required' => false,
253
            'filters' => [
254
                ['name' => \Laminas\Filter\StripTags::class],
255
                ['name' => \Laminas\Filter\StringTrim::class],
256
            ],
257
            'validators' => [
258
                [
259
                    'name' => \Laminas\Validator\StringLength::class,
260
                    'options' => [
261
                        'encoding' => 'UTF-8',
262
                        'max' => 25,
263
                    ],
264
                ],
265
                [
266
                    'name' => \Laminas\Validator\NotEmpty::class,
267
                ],
268
            ],
269
        ]);
270
 
271
        $this->add([
272
            'name' => 'phone_extension',
273
            'required' => false,
274
            'filters' => [
275
                ['name' => \Laminas\Filter\StripTags::class],
276
                ['name' => \Laminas\Filter\StringTrim::class],
277
            ],
278
            'validators' => [
279
                [
280
                    'name' => \Laminas\Validator\StringLength::class,
281
                    'options' => [
282
                        'encoding' => 'UTF-8',
283
                        'max' => 5,
284
                    ],
285
                ],
286
                [
287
                    'name' => \Laminas\Validator\NotEmpty::class,
288
                ],
289
            ],
290
        ]);
291
 
292
        $this->add([
293
            'name' => 'celular',
294
            'required' => false,
295
            'filters' => [
296
                ['name' => \Laminas\Filter\StripTags::class],
297
                ['name' => \Laminas\Filter\StringTrim::class],
298
            ],
299
            'validators' => [
300
                [
301
                    'name' => \Laminas\Validator\StringLength::class,
302
                    'options' => [
303
                        'encoding' => 'UTF-8',
304
                        'max' => 25,
305
                    ],
306
                ],
307
                [
308
                    'name' => \Laminas\Validator\NotEmpty::class,
309
                ],
310
            ],
311
        ]);
312
 
313
        $this->add([
314
            'name' => 'whatsapp',
315
            'required' => false,
316
            'filters' => [
317
                ['name' => \Laminas\Filter\StripTags::class],
318
                ['name' => \Laminas\Filter\StringTrim::class],
319
            ],
320
            'validators' => [
321
                [
322
                    'name' => \Laminas\Validator\StringLength::class,
323
                    'options' => [
324
                        'encoding' => 'UTF-8',
325
                        'max' => 25,
326
                    ],
327
                ],
328
                [
329
                    'name' => \Laminas\Validator\NotEmpty::class,
330
                ],
331
            ],
332
        ]);
333
 
334
 
335
 
336
        $this->add([
337
            'name' => 'linkedin',
338
            'required' => false,
339
            'filters' => [
340
                ['name' => \Laminas\Filter\StripTags::class],
341
                ['name' => \Laminas\Filter\StringTrim::class],
342
            ],
343
            'validators' => [
344
                [
345
                    'name' => \Laminas\Validator\StringLength::class,
346
                    'options' => [
347
                        'encoding' => 'UTF-8',
348
                        'max' => 250,
349
                    ],
350
                ],
351
                [
352
                    'name' => \Laminas\Validator\NotEmpty::class,
353
                ],
354
                [
355
                    'name' => \Laminas\Validator\Uri::class,
356
                ],
357
            ],
358
        ]);
359
 
360
 
361
 
15831 efrain 362
        $this->add([
363
            'name' => 'sector',
364
            'required' => false,
365
            'filters' => [
366
                ['name' => \Laminas\Filter\StripTags::class],
367
                ['name' => \Laminas\Filter\StringTrim::class],
368
            ],
369
            'validators' => [
370
                [
371
                    'name' => \Laminas\Validator\StringLength::class,
372
                    'options' => [
373
                        'encoding' => 'UTF-8',
374
                        'max' => 250,
375
                    ],
376
                ],
377
                [
378
                    'name' => \Laminas\Validator\NotEmpty::class,
379
                ],
380
            ],
381
        ]);
16766 efrain 382
 
383
        $this->add([
384
            'name' => 'scholarship',
385
            'required' => false,
386
            'filters' => [
387
                ['name' => \Laminas\Filter\StripTags::class],
388
                ['name' => \Laminas\Filter\StringTrim::class],
389
            ],
390
            'validators' => [
391
                [
392
                    'name' => \Laminas\Validator\StringLength::class,
393
                    'options' => [
394
                        'encoding' => 'UTF-8',
395
                        'max' => 250,
396
                    ],
397
                ],
398
                [
399
                    'name' => \Laminas\Validator\NotEmpty::class,
400
                ],
401
            ],
402
        ]);
15398 efrain 403
    }
404
}