Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should not return an error if boxed string value\'s length is equal to minLength', () => {
expect(minLength(2)(box('ab'))).toEqual({});
});
it('should return errors with comparand and actual properties for boxed value', () => {
const comparand = 1;
const actual = box(0);
expect(greaterThan(comparand)(actual)).toEqual({
greaterThan: {
comparand,
actual: unbox(actual),
},
});
});
it('should not return an error if boxed value is less than comparand', () => {
expect(lessThan(1)(box(0))).toEqual({});
});
it('should return an error for boxed false', () => {
const value = box(false);
expect(requiredTrue(value)).toEqual({
required: {
actual: unbox(value),
},
});
});
it('should return errors with comparand and actual properties for boxed value', () => {
const comparand = 1;
const actualValue = box(1);
expect(notEqualTo(comparand)(actualValue)).toEqual({
notEqualTo: {
comparand,
actual: unbox(actualValue),
},
});
});
it('should return an error for boxed undefined', () => {
const value = box(undefined);
expect(required(value)).toEqual({
required: {
actual: unbox(value),
},
});
});
it('should not return an error if boxed string value\'s length is equal to maxLength', () => {
expect(maxLength(2)(box('ab'))).toEqual({});
});
it('should work for boxed strings', () => {
expect(required(box('a'))).toEqual({});
});
it('should return an error for boxed empty array', () => {
const value = box([] as any[]);
expect(required(value)).toEqual({
required: {
actual: unbox(value),
},
});
});
readonly type = SetSubmittedValueAction.TYPE;
constructor(public submittedValue: FormValue) { }
}
export const FORM_ID = 'material';
export const INITIAL_STATE = createFormGroupState(FORM_ID, {
userName: '',
createAccount: true,
password: {
password: '',
confirmPassword: '',
},
sex: '',
favoriteColor: '',
hobbies: box([]),
dateOfBirth: new Date(Date.UTC(1970, 0, 1)).toISOString(),
agreeToTermsOfUse: false,
});
const validationFormGroupReducer = createFormStateReducerWithUpdate(updateGroup({
userName: validate(required),
password: (state, parentState) => {
if (!parentState.value.createAccount) {
return disable(state);
}
state = enable(state);
return updateGroup(state, {
password: validate(required, minLength(8)),
confirmPassword: validate(equalTo(state.value.password)),
});