Replies: 6 comments
-
Hello @OAFCROB, That sounds like a fun new feature! First things first: creating a validator can be done in multiple ways, with different kind of configuration files.
Currently I am using YAML in one of our projects. The validator creating looks like this: class ValidatorFactory
{
public static function create(string $configDir): ValidatorInterface
{
return Validation::createValidatorBuilder()
->addYamlMappings(iterator_to_array(
Finder::create()
->files()
->in($configDir)
->name('*.yaml')
))
->getValidator();
}
} If you don't like yaml, you could always go for annotations or xml. However, it is not possible to provide an XSD and let the validator find out what to do. It is validating PHP objects with validator specific configuration. This will require some xsd to validator configuration transformation. (The part above is something we could add to the documentation) About the validator config generation: there are some things we could do... First thing you need to know is that we are currently limited by the info provided by ext-soap in this package. We are parsing However, it is possible to create your own As a last possible solution: it might also be possible to create an HTTP middleware that validates the request / response XML based on the XSD in the WSDL (with Feel free to play around with this! :) |
Beta Was this translation helpful? Give feedback.
-
@veewee thanks for the reply, it would be super awesome to even have some basic validation auto-generated. Will have to a play around with it and see what we can achieve. |
Beta Was this translation helpful? Give feedback.
-
You can add mapper tag |
Beta Was this translation helpful? Give feedback.
-
@OAFCROB Does https://github.com/goetas-webservices/xsd2php do the job? |
Beta Was this translation helpful? Give feedback.
-
@whatUwant that looks interesting, will have to bear that in mind for future projects 😀 |
Beta Was this translation helpful? Give feedback.
-
FYI : we are planning to improve the metadata that can be used to generate code, but it will take some time ... :) |
Beta Was this translation helpful? Give feedback.
-
Support Question
Is it possible to auto-generate the Symphony validation rules from the WDSL/XSD?
The documentation states that you can include the validator subscriber into your factor method but doesn't give an example of how to define
$validator
.I assume that you're supposed to initiate an instance of the Symphony validator and associate the rules to the instance?
What I was wondering though, is it possible to automatically generate the validation rules for the request from the WDSL or the XSD file?
The WDSL we have is provided to us via a third-party client and we're using this package to make the SOAP calls but ideally, we would like to request exceptions of invalid data format i.e. missing parameters rather than the current SOAP exceptions we're currently getting.
Could you do something like this;
Beta Was this translation helpful? Give feedback.
All reactions