
package com.xxx.validator;

import com.isomorphic.datasource.DataSource;
import com.isomorphic.datasource.Validator;
import com.isomorphic.rpc.RPCManager;

import java.util.Map;

import org.springframework.stereotype.Service;


@Service("testValidator")
public class FirstDsValidator{


	/**
	 * Condition.
	 * 
	 * @param value
	 *            the value
	 * @param validator
	 *            the validator
	 * @param fieldName
	 *            the field name
	 * @param record
	 *            the record
	 * @param ds
	 *            the ds
	 * @param rpc
	 *            the rpc
	 * @return true, if successful
	 */
	public boolean checkFirstNm(final Object value, final Validator validator,
			final String fieldName, final Map record, final DataSource ds,
			final RPCManager rpc) {
		boolean status = true;
		if(value !=null && value.equals(record.get("secondNm"))){
			status = false;
			validator.addErrorMessageVariable(fieldName,
					"First name can not be same as Second name");
		}
		return status;
	}
	
	/**
	 * Condition.
	 * 
	 * @param value
	 *            the value
	 * @param validator
	 *            the validator
	 * @param fieldName
	 *            the field name
	 * @param record
	 *            the record
	 * @param ds
	 *            the ds
	 * @param rpc
	 *            the rpc
	 * @return true, if successful
	 */
	public boolean checkSecondNm(final Object value, final Validator validator,
			final String fieldName, final Map record, final DataSource ds,
			final RPCManager rpc) {
		boolean status = true;
		if(value !=null && value.equals(record.get("firstNm"))){
			status = false;
			validator.addErrorMessageVariable(fieldName,
					"First name can not be same as Second name");
		}
		return status;
	}
}
