One method, rules(), returning what to validate per source. It is deliberately declarative:
a contract that describes itself can be read by @stone-js/openapi to publish the request
schema, which a method that merely validated could never be.
The class is resolved by the container, so its constructor receives services and rules() can use
them. That is what makes translated messages possible without a second method for them:
The same class validates a form on the frontend, because nothing here knows about HTTP: resolve it
from the container and call rules(), or hand it to the Validator directly. One schema, both
sides, which is the whole reason the module is agnostic.
The contract a schema class exposes.
One method,
rules(), returning what to validate per source. It is deliberately declarative: a contract that describes itself can be read by@stone-js/openapito publish the request schema, which a method that merely validated could never be.The class is resolved by the container, so its constructor receives services and
rules()can use them. That is what makes translated messages possible without a second method for them:The same class validates a form on the frontend, because nothing here knows about HTTP: resolve it from the container and call
rules(), or hand it to theValidatordirectly. One schema, both sides, which is the whole reason the module is agnostic.