diff --git a/src/Annotation/AbstractValidation.php b/src/Annotation/AbstractValidation.php index 8669808..5db58b6 100644 --- a/src/Annotation/AbstractValidation.php +++ b/src/Annotation/AbstractValidation.php @@ -4,8 +4,12 @@ namespace Ray\WebFormModule\Annotation; +/** + * Base of the attributes that validate the input with a form before the method runs + */ abstract class AbstractValidation { + /** @param string $form Name of the property that holds the form */ public function __construct(public string $form = 'form') { } diff --git a/src/Annotation/CsrfProtection.php b/src/Annotation/CsrfProtection.php index c40a0a4..49a8de5 100644 --- a/src/Annotation/CsrfProtection.php +++ b/src/Annotation/CsrfProtection.php @@ -6,6 +6,11 @@ use Attribute; +/** + * Makes the validating form check the CSRF token and throw CsrfViolationException on mismatch + * + * @see https://bearsunday.github.io/manuals/1.0/en/form.html#csrf-protections + */ #[Attribute(Attribute::TARGET_METHOD)] final class CsrfProtection { diff --git a/src/Annotation/FormValidation.php b/src/Annotation/FormValidation.php index c852267..322679d 100644 --- a/src/Annotation/FormValidation.php +++ b/src/Annotation/FormValidation.php @@ -6,9 +6,20 @@ use Attribute; +/** + * Validates the input with the form before the method runs and hands a failure to the failure handler + * + * @see https://bearsunday.github.io/manuals/1.0/en/form.html#controller + * @see \Ray\WebFormModule\AuraInputInterceptor + */ #[Attribute(Attribute::TARGET_METHOD)] final class FormValidation extends AbstractValidation { + /** + * @param string $form Name of the property that holds the form + * @param string|null $onFailure Method called on failure, `ValidationFailed` when null; + * FormVndErrorModule throws ValidationException without calling it + */ public function __construct( string $form = 'form', public string|null $onFailure = null, diff --git a/src/Annotation/InputValidation.php b/src/Annotation/InputValidation.php index 77c1407..b2d88b7 100644 --- a/src/Annotation/InputValidation.php +++ b/src/Annotation/InputValidation.php @@ -6,6 +6,12 @@ use Attribute; +/** + * Validates the input with the form before the method runs and throws ValidationException on failure + * + * @see https://bearsunday.github.io/manuals/1.0/en/form.html#validation-exception + * @see \Ray\WebFormModule\InputValidationInterceptor + */ #[Attribute(Attribute::TARGET_METHOD)] final class InputValidation extends AbstractValidation { diff --git a/src/Annotation/VndError.php b/src/Annotation/VndError.php index 34c5a56..0f5f9ec 100644 --- a/src/Annotation/VndError.php +++ b/src/Annotation/VndError.php @@ -6,11 +6,17 @@ use Attribute; +/** + * Sets the message, path, logref and links of the vnd.error body when validation fails + * VndErrorHandler reads it for #[InputValidation], and for #[FormValidation] when FormVndErrorModule is installed + * + * @see https://bearsunday.github.io/manuals/1.0/en/form.html#validation-exception + */ #[Attribute(Attribute::TARGET_METHOD)] final class VndError { /** - * @param array $href + * @param array $href URIs keyed by link relation, e.g. `help` * * @see http://www.w3.org/TR/html5/links.html#link-type-help * @see http://tools.ietf.org/html/rfc6903#section-2