Rules Validate Iframe

Hi mates!

How would have validate an html iframe as of the rules() model?

Only to use the pattern "iframe width=" is enough, because the user has only to copy paste a iframe link from GoogleMaps (to try to validate that user copy a correct link: iframe and not an url or another html code)

I try it without success with:

  1. array(‘link_gmaps’, ‘url’, ‘validSchemes’=>‘iframe’),

  2. array(‘link_gmaps’, ‘url’, ‘defaultScheme’=>‘iframe’),


Use the match validator ( something like:

array('link_gmaps', 'match', 'pattern' => '/<iframe.*src="https:\/\/\/.*".*><\/iframe>/six'), 

And a FYI, iframe is not a url schema, is not like you could access something with iframe:// thing at which a url schema makes reference.

Many thanks twisted1919,

Your advice was very useful and the pattern was not correct but aproximate.

This is the solution:

array('link_gmaps', 'match', 'pattern' => '/<iframe[^>]*src="https:\/\/\/[^"]+">\s*<\/iframe>/six', 'message'=>'{attribute} is invalid, must be an iframe.'),