Merge pull request #25 from TouchInstinct/feature/validation_full_validate_method
fullValidateAndGetModel
This commit is contained in:
commit
333e6b7fcb
|
|
@ -145,6 +145,7 @@ public abstract class EditTextValidator<TModel extends Serializable> extends Val
|
|||
* Model can be null if validation fails on primary or final checks.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public Observable<HalfNullablePair<ValidationState, TModel>> fullValidateAndGetModel(@NonNull final String text) {
|
||||
return createValidationObservable(text, true)
|
||||
.first();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@ import android.support.annotation.NonNull;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import ru.touchin.roboswag.core.utils.pairs.HalfNullablePair;
|
||||
import ru.touchin.templates.validation.ValidationState;
|
||||
import rx.Observable;
|
||||
|
||||
import static ru.touchin.templates.validation.ValidationState.VALID;
|
||||
|
||||
/**
|
||||
* Created by Ilia Kurtov on 24/01/2017.
|
||||
* Class that simplifies work with {@link Validator}'s that have the same wrapper model and model type.
|
||||
|
|
@ -25,4 +31,16 @@ public class SameTypeValidator<TModel extends Serializable> extends Validator<TM
|
|||
return wrapperModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates {@link TModel} and returns {@link Observable} with {@link HalfNullablePair} of final state and resulting model.
|
||||
* @param wrapperModel - not null value that should be validated.
|
||||
* @return pair with final {@link ValidationState} that is always not null and a model that we get after converting the {@link TModel}.
|
||||
* Model can be null if validation fails.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public Observable<HalfNullablePair<ValidationState, TModel>> fullValidateAndGetModel(@NonNull final TModel wrapperModel) {
|
||||
return Observable.just(new HalfNullablePair<>(VALID, wrapperModel));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ import java.io.Serializable;
|
|||
|
||||
import ru.touchin.roboswag.core.observables.Changeable;
|
||||
import ru.touchin.roboswag.core.observables.NonNullChangeable;
|
||||
import ru.touchin.roboswag.core.utils.pairs.HalfNullablePair;
|
||||
import ru.touchin.templates.validation.ValidationState;
|
||||
import rx.Observable;
|
||||
|
||||
/**
|
||||
* Created by Ilia Kurtov on 24/01/2017.
|
||||
|
|
@ -87,4 +89,13 @@ public abstract class Validator<TWrapperModel extends Serializable, TModel exten
|
|||
return validationStateWhenEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates {@link TWrapperModel} and returns {@link Observable} with {@link HalfNullablePair} of final state and resulting model.
|
||||
* @param wrapperModel - not null value that should be validated.
|
||||
* @return pair with final {@link ValidationState} that is always not null and a model that we get after converting the {@link TWrapperModel}.
|
||||
* Model can be null if validation fails.
|
||||
*/
|
||||
@NonNull
|
||||
public abstract Observable<HalfNullablePair<ValidationState, TModel>> fullValidateAndGetModel(@NonNull final TWrapperModel wrapperModel);
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue