Closed nervo closed 2 weeks ago
Hey I actually like the implementation more here but let's not deprecate Value
as that API is much easier to use.
I like how currently the Value method simply is a shorthand for the proposed way of a pointer accessor.
@maaslalani ok, let's undeprecate Value, fine π
What about wording ? Do you agree with Accessor
, EmbeddedAccessor
and PointerAccessor
?
Another point that bugs me is error handling :( In a perfect world, a setter/getter should return errors, but i can't see a way to handle them without breaking the current interfaces...
@maaslalani ok, let's undeprecate Value, fine π What about wording ? Do you agree with
Accessor
,EmbeddedAccessor
andPointerAccessor
?Another point that bugs me is error handling :( In a perfect world, a setter/getter should return errors, but i can't see a way to handle them without breaking the current interfaces...
You can have a Validator
that wraps an accessor which does the error handling I believe.
Fantastic work @nervo. Thank you for this!
Wow, that was fast β€οΈ
This pr introduce a new (and simple)
Accessor
interface to enhance the form field values handling in a fully backward compatible way.This interface is generic and contains only two method
Set
(for - guess what - setting value) anGet
(you got it, for getting value).The
Value
method of fields is very limited, and give only one way to expose fields values - via a variable pointer - with no other possibilities.I propose to deprecate it in favor of anI propose a newAccessor
to define well... the field accessor :)Accessor
method to define well... the field accessor :) Under the hood,Value
method still exists but makes usage of an accessor.Two generics accessors are already available:
EmbeddedAccessor
which replace the current behavior of fields when no variable pointer has been defined viaValue
method.PointerAccessor
wich replace the current behavior of fields when a variable pointer is defined viaValue
method.Custom accessors can now be defined by end users :)