Giter Site home page Giter Site logo

Comments (2)

kprovance avatar kprovance commented on August 17, 2024

In the future, please use the issue tracker here: (https://github.com/reduxframework/redux-framework). This beta repo is closed. I'll ask to have it taken down.

Change your validation function to this:

function validate_json( $field, $value, $existing_value ) {
	$json = json_decode( $value );

	if ( json_last_error() === JSON_ERROR_NONE ) {
		$field['msg'] = '';
		return array( 
			'value' => trim( $value ), 
			'error' => $field 
		);
	}

	$field['msg'] = esc_html__( 'You must enter valid JSON.', 'text-domain' );

	return array(
		'error' => $field,
		'value' => trim( $existing_value ),
	);
}

For custom validations, you'll have to pass a null or empty value to the field error and return it to make the message disappear on success.

from redux-framework-4.

sjregan avatar sjregan commented on August 17, 2024

Thanks for your response, I've opened a new issue in the other repo as the issue is JavaScript related, not PHP. So, while the validate_json() function was incorrect, it is unrelated to the bug.

from redux-framework-4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.