northrook / types
PHP的自验证数据类型
dev-main
2024-06-12 07:49 UTC
Requires
- php: >=8.1
- meyfa/php-svg: ^0.15.0
- northrook/email-validator: dev-main
- northrook/logger: dev-main
- northrook/password-validator: dev-main
- northrook/support: dev-main
- symfony/uid: ^7.0
Requires (Dev)
- symfony/var-dumper: ^7.0
This package is auto-updated.
Last update: 2024-09-12 08:18:03 UTC
README
更新值
创建 public function update($value)
,其中参数 $value
需要与类型匹配。
此方法可以用于处理额外的逻辑,只要它导致一个有效的 $value
。
使用 $this->updateValue( $value )
赋予更新的值。
除非传递 revalidate: false
,否则 updateValue
方法会重新验证新值。
该方法必须返回自身。
// Example: class CustomType extends Type { public function update( ?string $value ): self { $this->updateValue( $value ); return $this; } }