LLMS_Form_Validator::validate_field_attribute_minlength( string $posted_value, int $minlength, array $field )

Validates the html input minlength attribute


Description Description

Used by the User Password field.


Top ↑

Parameters Parameters

$posted_value

(string) (Required) User-submitted value.

$minlength

(int) (Required) The minimum string length as parsed from the field block.

$field

(array) (Required) LifterLMS Form Field settings array.


Top ↑

Return Return

(WP_Error|boolean) Returns true for a valid value, otherwise an error.


Top ↑

Source Source

File: includes/forms/class-llms-form-validator.php

	protected function validate_field_attribute_minlength( $posted_value, $minlength, $field ) {

		if ( strlen( $posted_value ) < $minlength ) {
			return new WP_Error(
				'llms-form-field-invalid',
				sprintf(
					__( 'The %1$s must be at least %2$d characters in length.', 'lifterlms' ),
					isset( $field['label'] ) ? $field['label'] : $field['name'],
					$minlength
				)
			);
		}

		return true;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.