laminas/laminas-validator

Improvement to laminas-validator documentation

tempfirstuser opened this issue · 3 comments

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

I use apigility (yes, I didn't upgraded yet) for REST/RPC requests from ajax calls which means I configure everything in config files.
I just needed to create custom validator which will search in db if record exists with some conditions. I was trying to create service factory for that and pass service manager (which use doctrine) to validator __construct method, but it looks like doesn't work in such way. I was trying to do like this:

'service_manager' => [
	'factories' => [
	    Validator\EmailExistsAndConfirmed::class        => Validator\Factory\EmailExistsAndConfirmedFactory::class,
	],
],

but it doesn't work.

I didn't find anything on docs about that I should create validator factory and put it into config like this:

'validators' => [
	'factories' => [
	    Validator\EmailExistsAndConfirmed::class        => Validator\Factory\EmailExistsAndConfirmedFactory::class,
	],
],

It would be great to keep such hint in docs. If I missed this in docs, then sorry about that.

Thanks for reporting this, @tempfirstuser. I'll do a little bit of research and experimentation and then update the docs accordingly.

@settermjd
The entire description for the validator plugin manager is missing and a cookbook recipe, how to register a custom validator in a laminas-mvc based application.

Saw that. I'm just getting myself back up to speed with knowing how it all works again and I'll get the documentation updated.