src/EntityDescriptor/EntityDescriptor.php
public function validateFieldValue($fieldName, &$value, $input=array(), $ref=null) {
		if( !isset($this->fields[$fieldName]) ) {
			throw new InvalidFieldException('unknownField', $fieldName, $value, null, $this->name);
		}
		$field = $this->getField($fieldName);
		if( !$field->writable ) {
			throw new InvalidFieldException('readOnlyField', $fieldName, $value, null, $this->name);
		}
		$TYPE = $field->getType();
		
		$TYPE->preFormat($field, $value, $input, $ref);
		
		if( $value === NULL || ($value==='' && $TYPE->emptyIsNull($field)) ) {
			$value	= null;
			if( isset($field->default) ) {
				// Look for default value
				$value	= $field->getDefault();
				
			} else
			if( !$field->nullable ) {
				// Reject null value 
				throw new InvalidFieldException('requiredField', $fieldName, $value, null, $this->name);
			}
			// We will format valid null value later (in formatter)
			return;
		}
		// TYPE Validator - Use inheritance, mandatory in super class
		try {
			$TYPE->validate($field, $value, $input, $ref);
			// Field Validator - Could be undefined
			if( !empty($field->validator) ) {
				call_user_func_array($field->validator, array($field, &$value, $input, &$ref));
			}
		} catch( FE $e ) {
			throw new InvalidFieldException($e->getMessage(), $fieldName, $value, $field->type, $this->name, $field->args);
		}

		// TYPE Formatter - Use inheritance, mandatory in super class
		$TYPE->format($field, $value);
		// Field Formatter - Could be undefined
	}
public function validateFieldValue($fieldName, &$value, $input=array(), $ref=null) {
		if( !isset($this->fields[$fieldName]) ) {
			throw new InvalidFieldException('unknownField', $fieldName, $value, null, $this->name);
		}
		$field = $this->getField($fieldName);
		if( !$field->writable ) {
			throw new InvalidFieldException('readOnlyField', $fieldName, $value, null, $this->name);
		}
		$TYPE = $field->getType();
		
		$TYPE->preFormat($field, $value, $input, $ref);
		
		if( $value === NULL || ($value==='' && $TYPE->emptyIsNull($field)) ) {
			$value	= null;
			if( isset($field->default) ) {
				// Look for default value
				$value	= $field->getDefault();
				
			} else
			if( !$field->nullable ) {
				// Reject null value 
				throw new InvalidFieldException('requiredField', $fieldName, $value, null, $this->name);
			}
			// We will format valid null value later (in formatter)
			return;
		}
		// TYPE Validator - Use inheritance, mandatory in super class
		try {
			$TYPE->validate($field, $value, $input, $ref);
			// Field Validator - Could be undefined
			if( !empty($field->validator) ) {
				call_user_func_array($field->validator, array($field, &$value, $input, &$ref));
			}
		} catch( FE $e ) {
			throw new InvalidFieldException($e->getMessage(), $fieldName, $value, $field->type, $this->name, $field->args);
		}

		// TYPE Formatter - Use inheritance, mandatory in super class
		$TYPE->format($field, $value);
		// Field Formatter - Could be undefined
	}
public function validateFieldValue ( $ fieldName , & $ value , $ input = array ( ) , $ ref = null ) { if ( ! isset ( $ this -> fields [ $ fieldName ] ) ) { throw new InvalidFieldException ( 'unknownField' , $ fieldName , $ value , null , $ this -> name ) ; } $ field = $ this -> getField ( $ fieldName ) ; if ( ! $ field -> writable ) { throw new InvalidFieldException ( 'readOnlyField' , $ fieldName , $ value , null , $ this -> name ) ; } $ TYPE = $ field -> getType ( ) ; $ TYPE -> preFormat ( $ field , $ value , $ input , $ ref ) ; if ( $ value === NULL || ( $ value === '' && $ TYPE -> emptyIsNull ( $ field ) ) ) { $ value = null ; if ( isset ( $ field -> default ) ) { // Look for default value $ value = $ field -> getDefault ( ) ; } else if ( ! $ field -> nullable ) { // Reject null value  throw new InvalidFieldException ( 'requiredField' , $ fieldName , $ value , null , $ this -> name ) ; } // We will format valid null value later (in formatter) return ; } // TYPE Validator - Use inheritance, mandatory in super class try { $ TYPE -> validate ( $ field , $ value , $ input , $ ref ) ; // Field Validator - Could be undefined if ( ! empty ( $ field -> validator ) ) { call_user_func_array ( $ field -> validator , array ( $ field , & $ value , $ input , & $ ref ) ) ; } } catch ( FE $ e ) { throw new InvalidFieldException ( $ e -> getMessage ( ) , $ fieldName , $ value , $ field -> type , $ this -> name , $ field -> args ) ; } // TYPE Formatter - Use inheritance, mandatory in super class $ TYPE -> format ( $ field , $ value ) ; // Field Formatter - Could be undefined }
Validate a value for a specified field, an exception is thrown if the value is invalid

@param	string $fieldName The field to use
@param	mixed $value input|output value to validate for this field
@param	$input string[]
@param	PermanentEntity $ref
@throws	InvalidFieldException
Validate a value for a specified field an exception is thrown if the value is invalid