userfrosting / fortress

A schema-driven system for elegant whitelisting, transformation and validation of user input on both the client and server sides from a unified set of rules.
Other
25 stars 9 forks source link

Allow schemas to be extended #17

Closed abdullahseba closed 7 years ago

abdullahseba commented 7 years ago

Allow schemas to be extended from other sprinkles without overriding the original schema.

alexweissman commented 7 years ago

Are you thinking that this should happen automatically for schema of the same name in each Sprinkle? Or is this something that you should have to do explicitly?

abdullahseba commented 7 years ago

Automatically I guess.

alexweissman commented 7 years ago

notsure

alexweissman commented 7 years ago

I am going to leave the default behavior for now, to only load the version of a request schema in the most recently loaded Sprinkle. However, you can still directly extend schema with arrays (see #1), OR you may use the StreamPathBuilder to load paths to all versions of your schema file, and YamlFileLoader to automatically merge the together:

        $builder = new StreamPathBuilder($this->ci->locator, 'schema://contact.yaml');
        $loader = new YamlFileLoader($builder->buildPaths());
        $schema = new RequestSchemaRepository($loader->load());

You can also write a custom PathBuilder or FileRepositoryLoader to find and combine schema in whatever manner you see fit.