Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAC key-value validation feature request #25

Open
Pitometsu opened this issue Oct 30, 2016 · 1 comment
Open

RAC key-value validation feature request #25

Pitometsu opened this issue Oct 30, 2016 · 1 comment

Comments

@Pitometsu
Copy link
Contributor

Pitometsu commented Oct 30, 2016

As a programmer,
I want to have ability to use KVV (key-value validation) when do KVC via RAC
to reduce duplication
and avoid model properties key-path hard-coding each time.


Do something like this

    RACSignal *usernameSignal = [RACObserve(self, username) map:^RACTuple *_Nonnull(id _Nullable value) {
        NSError *error;
        return
        RACTuplePack(
        @([self.credentials validateValue:&value
                               forKeyPath:@"username"
                                    error:&error]),
                     error);
    }];

    self.usernameValidation = [usernameSignal map:^NSError *_Nullable(RACTuple *_Nonnull tuple) {
        return tuple.second;
    }];
    RAC(self.credentials, username) = [[RACObserve(self, username) zipWith:usernameSignal]
                                       filter:^BOOL(RACTuple *_Nonnull tuple) {
                                           return tuple.second;
                                       }];

In way like

    [RAC(self.credentials, username)
     validateTo:self.usernameValidation] = RACObserve(self, username);

Where

  • self - view modeller
  • self.credentials - model
  • self.username - data to validate
  • self.credentials.username - validating property
  • self.usernameValidation - signal with results of validation.
@Pitometsu Pitometsu changed the title RAC validation feature request RAC key-value validation feature request Oct 30, 2016
@Pitometsu
Copy link
Contributor Author

Is it possible to implement such behaviour with current codebase to avoid a lot of code duplication on each validated property?

Can't figure out it by myself because of heavy macros usage in RACSubscriptingAssignmentTrampoline.

byohay pushed a commit to byohay/ReactiveObjC that referenced this issue Dec 14, 2021
…lity

RACSubject: Fix nullability annotation to match header.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant