public boolean validate()

in src/java/org/apache/fulcrum/intake/model/Field.java [638:716]


    public boolean validate()
    {
        log.debug(name + ": validate()");
        Validator<T> v = getValidator();

        if (isMultiValued())
        {
            stringValues = parser.getStrings(getKey());

            if (log.isDebugEnabled())
            {
                log.debug(name + ": Multi-Valued, Value is " + stringValue);
                if (stringValues != null)
                {
                    for (int i = 0; i < stringValues.length; i++)
                    {
                        log.debug(name + ": " + i + ". Value: " + stringValues[i]);
                    }
                }
            }

            if (v != null)
            {
                // set the test value as a String[] which might be replaced by
                // the correct type if the input is valid.
                setTestValue(stringValues);

                try
                {
                    v.assertValidity(this);
                }
                catch (ValidationException ve)
                {
                    setMessage(ve.getMessage());
                }
            }

            if (validFlag)
            {
                doSetValue();
            }
        }
        else
        {
            stringValue = parser.getString(getKey());

            if (log.isDebugEnabled())
            {
                log.debug(name + ": Single Valued, Value is " + stringValue);
            }

            if (v != null)
            {
                // set the test value as a String which might be replaced by
                // the correct type if the input is valid.
                setTestValue(stringValue);

                try
                {
                    v.assertValidity(this);
                    log.debug(name + ": Value is ok");
                    doSetValue();
                }
                catch (ValidationException ve)
                {
                    log.debug(name + ": Value failed validation!");
                    setMessage(ve.getMessage());
                }
            }
            else
            {
                doSetValue();
            }
        }

        validated = true;

        return validFlag;
    }