package com.braintreeocc.validators.impl;

import com.braintree.hybris.data.ws.BraintreeTokenizedCreditCardWsDTO;
import com.braintreeocc.validators.BrainTreeValidator;
import com.braintreeocc.constants.BraintreeoccWebConstants;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;

public class BraintreeTokenizedCreditCardDataValidator implements BrainTreeValidator {

    @Override
    public boolean supports(Class aClass) {
        return BraintreeTokenizedCreditCardWsDTO.class.isAssignableFrom(aClass);
    }

    @Override
    public void validate(Object target, Errors errors) {

        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "nonce", BraintreeoccWebConstants.FIELD_REQUIRED_MESSAGE_ID);
    }
}
